1########################################################################
2#
3# $Id: configure.in,v 1.101 2012/01/08 18:39:07 mavrik Exp $
4#
5########################################################################
6
7dnl ####################################################################
8dnl #
9dnl # Initialize.
10dnl #
11dnl ####################################################################
12
13AC_INIT(src/webjob.c)
14AC_PREREQ(2.53)
15AC_CONFIG_AUX_DIR(utils)
16AC_PREFIX_DEFAULT(/usr/local/webjob)
17cgidir='${exec_prefix}/cgi'
18docdir='${exec_prefix}/doc'
19etcdir='${exec_prefix}/etc'
20logdir='${exec_prefix}/log'
21mandir='${exec_prefix}/man'
22rundir='${exec_prefix}/run'
23AC_SUBST(cgidir)
24AC_SUBST(docdir)
25AC_SUBST(etcdir)
26AC_SUBST(logdir)
27AC_SUBST(mandir)
28AC_SUBST(rundir)
29
30ap_srcs=""
31ap_incs=""
32extension=""
33
34AC_CANONICAL_SYSTEM
35case "${target_os}" in
36*aix*)
37  OS_CFLAGS="-DUNIX"
38  AC_DEFINE(WEBJOB_AIX, 1, [Define to 1 if the target OS is AIX.])
39  AC_DEFINE(USE_AP_SNPRINTF, 1, [Define to 1 if snprintf() support is enabled.])
40  ac_cv_func_malloc_0_nonnull="yes"
41  ac_cv_func_realloc_0_nonnull="yes"
42  ap_srcs="ap_snprintf.c"
43  ap_incs="ap_snprintf.h"
44  ;;
45*bsd*)
46  OS_CFLAGS="-DUNIX"
47  AC_DEFINE(WEBJOB_BSD, 1, [Define to 1 if the target OS is BSD.])
48  ;;
49*cygwin*)
50  OS_CFLAGS="-DUNIX -DCYGWIN"
51  AC_DEFINE(WEBJOB_CYGWIN, 1, [Define to 1 if the target OS is Cygwin.])
52  extension=".exe"
53  ;;
54*darwin*)
55  OS_CFLAGS="-DUNIX"
56  AC_DEFINE(WEBJOB_MACOS, 1, [Define to 1 if the target OS is MacOS.])
57  ;;
58*hpux*)
59  OS_CFLAGS="-DUNIX"
60  AC_DEFINE(WEBJOB_HPUX, 1, [Define to 1 if the target OS is HP-UX.])
61  AC_DEFINE(USE_AP_SNPRINTF, 1, [Define to 1 if snprintf() support is enabled.])
62  ap_srcs="ap_snprintf.c"
63  ap_incs="ap_snprintf.h"
64  ;;
65*linux*)
66  OS_CFLAGS="-DUNIX"
67  LIBS="-ldl"
68  AC_DEFINE(WEBJOB_LINUX, 1, [Define to 1 if the target OS is Linux.])
69  case "${host_cpu}" in
70  arm)
71    ac_cv_func_malloc_0_nonnull="yes"
72    ac_cv_func_realloc_0_nonnull="yes"
73    ;;
74  *)
75    ;;
76  esac
77  ;;
78*mingw32*)
79  OS_CFLAGS="-DWIN32 -DMINGW32"
80  LIBS="-lwsock32 -lws2_32 -lgdi32"
81  AC_DEFINE(WEBJOB_MINGW32, 1, [Define to 1 if the target OS is MinGW32.])
82  ac_cv_func_malloc_0_nonnull="yes"
83  ac_cv_func_realloc_0_nonnull="yes"
84  extension=".exe"
85  ;;
86*solaris*)
87  OS_CFLAGS="-DUNIX"
88  LIBS="-ldl"
89  AC_DEFINE(WEBJOB_SOLARIS, 1, [Define to 1 if the target OS is Solaris.])
90  ;;
91*)
92  echo
93  echo "The target operating system, ${target_os}, is not currently supported."
94  echo
95  exit
96  ;;
97esac
98
99AC_SUBST(ap_srcs)
100AC_SUBST(ap_incs)
101AC_SUBST(extension)
102
103case ${host_cpu} in
104alpha*)
105  AC_DEFINE(APP_CPU_ALPHA, 1, [Define to 1 if the host cpu is alpha.])
106  ;;
107amd64*)
108  AC_DEFINE(APP_CPU_AMD64, 1, [Define to 1 if the host cpu is amd64.])
109  ;;
110arm*)
111  AC_DEFINE(APP_CPU_ARM, 1, [Define to 1 if the host cpu is arm.])
112  ;;
113hppa*)
114  AC_DEFINE(APP_CPU_HPPA, 1, [Define to 1 if the host cpu is hppa.])
115  ;;
116ia64*)
117  AC_DEFINE(APP_CPU_IA64, 1, [Define to 1 if the host cpu is ia64.])
118  ;;
119x86_64*)
120  AC_DEFINE(APP_CPU_X86_64, 1, [Define to 1 if the host cpu is x86_64.])
121  ;;
122i?86*)
123  AC_DEFINE(APP_CPU_I386, 1, [Define to 1 if the host cpu is iX86.])
124  ;;
125powerpc*)
126  AC_DEFINE(APP_CPU_POWERPC, 1, [Define to 1 if the host cpu is powerpc.])
127  ;;
128sparc*)
129  AC_DEFINE(APP_CPU_SPARC, 1, [Define to 1 if the host cpu is sparc.])
130  ;;
131*)
132  echo
133  echo "The target cpu, ${host_cpu}, is not currently supported."
134  echo
135  exit
136  ;;
137esac
138
139dnl ####################################################################
140dnl #
141dnl # Initialize CFLAGS before AC_PROG_CC does.
142dnl #
143dnl ####################################################################
144
145if test -n "${CFLAGS}" ; then
146  CFLAGS="${CFLAGS} -Wall ${OS_CFLAGS}"
147else
148  CFLAGS="-O2 -Wall ${OS_CFLAGS}"
149fi
150
151dnl ####################################################################
152dnl #
153dnl # Check for programs.
154dnl #
155dnl ####################################################################
156
157AC_PROG_AWK
158AC_PROG_CC
159AC_PROG_INSTALL
160AC_PROG_MAKE_SET
161AC_PROG_RANLIB
162
163dnl ####################################################################
164dnl #
165dnl # Check for libraries.
166dnl #
167dnl ####################################################################
168
169AC_CHECK_LIB(nsl, gethostbyname)
170AC_CHECK_LIB(socket, socket)
171
172dnl ####################################################################
173dnl #
174dnl # Check for header files.
175dnl #
176dnl ####################################################################
177
178AC_HEADER_DIRENT
179AC_HEADER_STDC
180AC_HEADER_SYS_WAIT
181AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h netdb.h netinet/in.h signal.h stdlib.h string.h strings.h sys/param.h sys/socket.h sys/statfs.h sys/statvfs.h sys/time.h sys/vfs.h unistd.h])
182
183AC_CHECK_HEADERS(sys/mount.h,,,
184  [
185    #if HAVE_SYS_TYPES_H
186    #include <sys/types.h>
187    #endif
188  ]
189)
190
191dnl ####################################################################
192dnl #
193dnl # Check for typedefs, structures, and compiler characteristics.
194dnl #
195dnl ####################################################################
196
197AC_C_CONST
198AC_TYPE_MODE_T
199AC_TYPE_SIZE_T
200AC_HEADER_TIME
201AC_SYS_LARGEFILE
202
203dnl ####################################################################
204dnl #
205dnl # Check for library functions.
206dnl #
207dnl ####################################################################
208
209AC_FUNC_CLOSEDIR_VOID
210AC_FUNC_FORK
211AC_FUNC_LSTAT
212AC_FUNC_MALLOC
213AC_FUNC_MEMCMP
214AC_FUNC_REALLOC
215AC_FUNC_STAT
216AC_FUNC_STRFTIME
217AC_CHECK_FUNCS([alarm fchdir getcwd getenv gethostbyname gettimeofday localtime_r longjmp kill memset mkdir modf putenv rmdir setenv setjmp snprintf socket strcasecmp strchr strerror strncasecmp strstr strtoul uname])
218
219case "${target_os}" in
220*bsd*)
221  AC_DEFINE(HAVE_DIRFD, 1, [Define to 1 if you have the 'dirfd' function.])
222  ;;
223*darwin*)
224  AC_DEFINE(HAVE_DIRFD, 1, [Define to 1 if you have the 'dirfd' function.])
225  ;;
226*)
227  AC_CHECK_FUNCS([dirfd])
228  ;;
229esac
230
231dnl ####################################################################
232dnl #
233dnl # Check for OpenSSL.
234dnl #
235dnl ####################################################################
236
237CheckSslComponents()
238{
239  SSLDIR=${1}
240  INCLUDE_LIST="crypto.h err.h pem.h rand.h ssl.h x509.h"
241  for INCLUDE_FILE in ${INCLUDE_LIST} ; do
242    if test ! -f "${SSLDIR}/include/openssl/${INCLUDE_FILE}" ; then
243      return 1
244    fi
245  done
246  ssldir=${SSLDIR}
247  return 0
248}
249
250AC_MSG_CHECKING([for OpenSSL support])
251AC_ARG_WITH(ssl,
252  [  --with-ssl=DIR          Use OpenSSL with includes and libs from [DIR]/include/openssl and [DIR]/lib
253  --without-ssl           Disable OpenSSL support],
254  [
255    dnl ################################################################
256    dnl #
257    dnl # Check the specified location only.
258    dnl #
259    dnl ################################################################
260    case `echo ${withval} | tr "A-Z" "a-z"` in
261    no)
262      use_ssl="0"
263      ;;
264    *)
265      use_ssl="1"
266      CheckSslComponents "${withval}"
267      ;;
268    esac
269  ],
270  [
271    dnl ################################################################
272    dnl #
273    dnl # Search common OpenSSL locations.
274    dnl #
275    dnl ################################################################
276    use_ssl="1"
277    for basedir in /usr /usr/local /usr/pkg /opt /opt/local ; do
278      for dir in ${basedir} ${basedir}/openssl ${basedir}/ssl ; do
279        CheckSslComponents ${dir} && break 2
280      done
281    done
282  ]
283)
284if test ${use_ssl} -ne 0 ; then
285  AC_DEFINE(USE_SSL, 1, [Define to 1 if OpenSSL support is enabled.])
286  if test -z "${ssldir}" ; then
287    AC_MSG_RESULT(missing or incomplete)
288    echo
289    echo "Unable to locate required OpenSSL components. Use --with-ssl=DIR to"
290    echo "specify a known/different location, or use --without-ssl to disable"
291    echo "this support. The following files must exist for this check to pass:"
292    echo
293    echo "  DIR/include/openssl/crypto.h"
294    echo "  DIR/include/openssl/err.h"
295    echo "  DIR/include/openssl/pem.h"
296    echo "  DIR/include/openssl/rand.h"
297    echo "  DIR/include/openssl/ssl.h"
298    echo "  DIR/include/openssl/x509.h"
299    echo
300    exit 1
301  else
302    AC_MSG_RESULT(${ssldir})
303    ssl_srcs="ssl.c"
304    ssl_incs="ssl.h ssl-pool.h"
305    ssl_incflags="-I${ssldir}/include"
306    ssl_libflags="-L${ssldir}/lib -lssl -lcrypto"
307    AC_SUBST(ssl_srcs)
308    AC_SUBST(ssl_incs)
309    AC_SUBST(ssl_incflags)
310    AC_SUBST(ssl_libflags)
311  fi
312else
313  AC_MSG_RESULT(check explicitly disabled)
314fi
315
316dnl ####################################################################
317dnl #
318dnl # Check for Lua.
319dnl #
320dnl ####################################################################
321
322CheckLua()
323{
324  LUADIR=${1}
325  INCLUDE_LIST="lua.h lualib.h lauxlib.h"
326  for INCLUDE_FILE in ${INCLUDE_LIST} ; do
327    if test ! -f "${LUADIR}/include/${INCLUDE_FILE}" ; then
328      return 1
329    fi
330  done
331  luadir=${LUADIR}
332  return 0
333}
334
335AC_MSG_CHECKING([for embedded Lua support])
336AC_ARG_WITH(lua,
337  [  --with-lua=DIR          Embed Lua with includes and libs from [DIR]/include and [DIR]/lib (disabled by default)],
338  [
339    dnl ################################################################
340    dnl #
341    dnl # Check the specified reference version only.
342    dnl #
343    dnl ################################################################
344    case `echo ${withval} | tr "A-Z" "a-z"` in
345    no)
346      use_lua="0"
347      ;;
348    *)
349      use_lua="1"
350      CheckLua "${withval}"
351      ;;
352    esac
353  ],
354  [
355    use_lua="0"
356  ]
357)
358if test ${use_lua} -ne 0 ; then
359  AC_DEFINE(USE_EMBEDDED_LUA, 1, [Define to 1 if embedded Lua support is enabled.])
360  if test -z "${luadir}" ; then
361    AC_MSG_RESULT(missing or incomplete)
362    echo
363    echo "Unable to locate required Lua components. Use --with-lua=DIR to"
364    echo "specify a known/different location. The following files must exist"
365    echo "for this check to pass:"
366    echo
367    echo "  DIR/include/lua.h"
368    echo "  DIR/include/lualib.h"
369    echo "  DIR/include/lauxlib.h"
370    echo
371    exit 1
372  else
373    AC_MSG_RESULT(${luadir})
374    lua_incflags="-I${luadir}/include"
375    lua_libflags="-L${luadir}/lib -llua -lm"
376    AC_SUBST(lua_incflags)
377    AC_SUBST(lua_libflags)
378  fi
379else
380  AC_MSG_RESULT(no)
381fi
382
383dnl ####################################################################
384dnl #
385dnl # Check for Perl.
386dnl #
387dnl ####################################################################
388
389CheckPerl()
390{
391  REFERENCE_PERL=${1}
392  if test ! -f "${REFERENCE_PERL}" ; then
393    return 1
394  fi
395  if test ! -x "${REFERENCE_PERL}" ; then
396    return 1
397  fi
398  perl_version=`${REFERENCE_PERL} -V:version | awk -F= '{print $2}' | sed "s/'//g; s/;//;"`
399  return 0
400}
401
402AC_MSG_CHECKING([for embedded Perl support])
403AC_ARG_WITH(perl,
404  [  --with-perl=PATH        Embed Perl using PATH as the reference version (disabled by default)],
405  [
406    dnl ################################################################
407    dnl #
408    dnl # Check the specified reference version only.
409    dnl #
410    dnl ################################################################
411    case `echo ${withval} | tr "A-Z" "a-z"` in
412    no)
413      use_perl="0"
414      ;;
415    *)
416      use_perl="1"
417      CheckPerl "${withval}"
418      ;;
419    esac
420  ],
421  [
422    use_perl="0"
423  ]
424)
425if test ${use_perl} -ne 0 ; then
426  AC_DEFINE(USE_EMBEDDED_PERL, 1, [Define to 1 if embedded Perl support is enabled.])
427  if test -z "${perl_version}" ; then
428    AC_MSG_RESULT(missing or incomplete)
429    echo
430    echo "Unable to locate required Perl components. Use --with-perl=PATH to"
431    echo "specify a known/different Perl binary."
432    echo
433    exit 1
434  else
435    AC_MSG_RESULT(${perl_version})
436    perl_cflags=`${REFERENCE_PERL} -MExtUtils::Embed -e ccflags`
437    case "${target_os}" in
438    *mingw32*)
439      perl_incflags=`${REFERENCE_PERL} -MExtUtils::Embed -e perl_inc | tr '\\\\' '/'`
440      perl_libflags=`${REFERENCE_PERL} -MExtUtils::Embed -e ldopts | tr '\\\\' '/'`
441      ;;
442    *)
443      perl_incflags=`${REFERENCE_PERL} -MExtUtils::Embed -e perl_inc`
444      perl_libflags=`${REFERENCE_PERL} -MExtUtils::Embed -e ldopts`
445      case `${REFERENCE_PERL} -V:usethreads` in
446      usethreads=?define??)
447        AC_DEFINE(USE_EMBEDDED_PERL_XSUB, 1, [Define to 1 if embedded Perl needs XSUB.h.])
448        ;;
449      esac
450      ;;
451    esac
452    perl5_lib="${prefix}/lib/perl5"
453    perl5_site_lib="${prefix}/lib/perl5/site_perl"
454    AC_DEFINE_UNQUOTED(PERL5LIB, "${perl5_site_lib}:${perl5_lib}", [Location of Perl library components specific to WebJob.])
455    AC_SUBST(perl_cflags)
456    AC_SUBST(perl_incflags)
457    AC_SUBST(perl_libflags)
458  fi
459else
460  AC_MSG_RESULT(no)
461fi
462
463dnl ####################################################################
464dnl #
465dnl # Check whether or not to include Digital Signature Verification
466dnl # (DSV) support. Note: DSV support is automatically disabled if SSL
467dnl # support is disabled (i.e., the user specified --without-ssl).
468dnl #
469dnl ####################################################################
470
471AC_MSG_CHECKING([whether to include Digital Signature Verification (DSV) support])
472AC_ARG_ENABLE(dsv,
473  [  --disable-dsv           Disable DSV support (enabled by default)],
474  [
475    case `echo ${enableval} | tr "A-Z" "a-z"` in
476    no)
477      enable_dsv="0"
478      ;;
479    *)
480      enable_dsv="1"
481      ;;
482    esac
483  ],
484  [
485    if test ${use_ssl} -eq 0 ; then
486      enable_dsv="0"
487    else
488      enable_dsv="1"
489    fi
490  ]
491)
492if test ${enable_dsv} -eq 1 ; then
493  if test ${use_ssl} -eq 0 ; then
494    AC_MSG_RESULT([OpenSSL support is required, but it has been explicitly disabled (aborting)])
495    exit 1
496  fi
497  AC_MSG_RESULT(yes)
498  AC_DEFINE(USE_DSV, 1, [Define to 1 if Digital Signature Verification (DSV) support is enabled.])
499  dsv_srcs="dsv.c"
500  dsv_incs="dsv.h dsv-pool.h"
501  AC_SUBST(dsv_srcs)
502  AC_SUBST(dsv_incs)
503else
504  AC_MSG_RESULT(no)
505fi
506
507dnl ####################################################################
508dnl #
509dnl # Check whether or not to enable pre-mem{set,cpy} hash logic.
510dnl #
511dnl ####################################################################
512
513AC_MSG_CHECKING([whether to enable pre-mem{set,cpy} hash logic])
514AC_ARG_ENABLE(hash-pre-msmc,
515  [  --enable-hash-pre-msmc  Enable pre-mem{set,cpy} hash logic (disabled by default)],
516  [ AC_MSG_RESULT(yes)
517    AC_DEFINE(MD5_PRE_MEMSET_MEMCPY, 1, [Define to 1 if pre-mem{set,cpy} hash logic is enabled.])
518    AC_DEFINE(SHA1_PRE_MEMSET_MEMCPY, 1, [Define to 1 if pre-mem{set,cpy} hash logic is enabled.])
519    AC_DEFINE(SHA256_PRE_MEMSET_MEMCPY, 1, [Define to 1 if pre-mem{set,cpy} hash logic is enabled.])
520  ],
521  [ AC_MSG_RESULT(no) ]
522)
523
524dnl ####################################################################
525dnl #
526dnl # Initialize variables needed by several follow-on sections.
527dnl #
528dnl ####################################################################
529
530install_lib_perl="0"
531
532doc_makefiles="doc/Makefile doc/webjob/Makefile"
533etc_makefiles="etc/Makefile etc/webjob-execute.cfg/Makefile etc/webjob-get-url.cfg/Makefile"
534lib_makefiles="lib/Makefile"
535test_makefiles="
536  tests/Makefile
537  tests/webjob/Makefile
538  tests/webjob/common/Makefile
539  tests/webjob/common/hashsum/Makefile
540  tests/webjob/common/hashsum/test_1/Makefile
541  tests/webjob/common/hashsum/test_2/Makefile
542  tests/webjob/common/hashsum/test_3/Makefile
543  "
544tool_makefiles="tools/Makefile"
545
546doc_subdirs="webjob"
547etc_subdirs="webjob-execute.cfg webjob-get-url.cfg"
548lib_subdirs=""
549test_subdirs="webjob"
550tool_subdirs=""
551
552tool_config_subdirs=""
553
554html_files="webjob.html"
555man1_files="webjob.1"
556
557dnl ####################################################################
558dnl #
559dnl # Check whether or not to install everything.
560dnl #
561dnl ####################################################################
562
563AC_MSG_CHECKING([whether to install everything])
564AC_ARG_WITH(everything,
565  [  --with-everything       Install everything (disabled by default)],
566  [
567    case `echo ${withval} | tr "A-Z" "a-z"` in
568    no)
569      install_everything="0"
570      ;;
571    *)
572      install_everything="1"
573      ;;
574    esac
575  ],
576  [
577    install_everything="0"
578  ]
579)
580if test ${install_everything} -ne 0 ; then
581  AC_MSG_RESULT(yes)
582else
583  AC_MSG_RESULT(no)
584fi
585
586dnl ####################################################################
587dnl #
588dnl # Check whether or not to install client-side components.
589dnl #
590dnl ####################################################################
591
592AC_MSG_CHECKING([whether to install client-side components])
593AC_ARG_WITH(client-side,
594  [  --with-client-side      Install client-side components (disabled by default)],
595  [
596    case `echo ${withval} | tr "A-Z" "a-z"` in
597    no)
598      install_client="0"
599      ;;
600    *)
601      install_client="1"
602      ;;
603    esac
604  ],
605  [
606    install_client="0"
607  ]
608)
609if test ${install_everything} -ne 0 -o ${install_client} -ne 0 ; then
610  AC_MSG_RESULT(yes)
611#  client_list="webjob-setup-cfgfiles webjob-setup-cronjobs"
612#  doc_subdirs="${doc_subdirs} ${client_list}"
613#  doc_makefiles="${doc_makefiles} "`{ for item in ${client_list} ; do echo ${item} | sed 's,^,doc/,; s,$,/Makefile,;' ; done ; } | tr '\n' ' '`
614#  html_files="${html_files} "`{ for item in ${client_list} ; do echo ${item} | sed 's/$/.html/;' ; done ; } | tr '\n' ' '`
615#  man1_files="${man1_files} "`{ for item in ${client_list} ; do echo ${item} | sed 's/$/.1/;' ; done ; } | tr '\n' ' '`
616#  tool_subdirs="${tool_subdirs} ${client_list}"
617#  tool_makefiles="${tool_makefiles} "`{ for item in ${client_list} ; do echo ${item} | sed 's,^,tools/,; s,$,/Makefile,;' ; done ; } | tr '\n' ' '`
618else
619  AC_MSG_RESULT(no)
620fi
621
622dnl ####################################################################
623dnl #
624dnl # Check whether or not to install server-side components.
625dnl #
626dnl ####################################################################
627
628AC_MSG_CHECKING([whether to install server-side components])
629AC_ARG_WITH(server-side,
630  [  --with-server-side      Install server-side components (disabled by default)],
631  [
632    case `echo ${withval} | tr "A-Z" "a-z"` in
633    no)
634      install_server="0"
635      ;;
636    *)
637      install_server="1"
638      ;;
639    esac
640  ],
641  [
642    install_server="0"
643  ]
644)
645if test ${install_everything} -ne 0 -o ${install_server} -ne 0 ; then
646  AC_MSG_RESULT(yes)
647  server_list="nph-config.cgi nph-webjob.cgi webjob-compress-upload webjob-create-account webjob-create-profile webjob-delete-account webjob-delete-profile webjob-lock-account webjob-lock-profile webjob-log-create-access-list webjob-log-roller webjob-setup-server"
648  common_commands_list="cronjob-manager queue-worker testenv testenv.cmd"
649  doc_subdirs="${doc_subdirs} ${server_list}"
650  doc_makefiles="${doc_makefiles} "`{ for item in ${server_list} ; do echo ${item} | sed 's,^,doc/,; s,$,/Makefile,;' ; done ; } | tr '\n' ' '`
651  etc_makefiles="${etc_makefiles} etc/nph-config.cfg/Makefile etc/nph-webjob.cfg/Makefile etc/server.cfg/Makefile"
652  etc_subdirs="${etc_subdirs} nph-config.cfg nph-webjob.cfg server.cfg"
653  html_files="${html_files} "`{ for item in ${server_list} ; do echo ${item} | sed 's/$/.html/;' ; done ; } | tr '\n' ' '`
654  man1_files="${man1_files} "`{ for item in ${server_list} ; do echo ${item} | sed 's/$/.1/;' ; done ; } | tr '\n' ' '`
655  tool_subdirs="${tool_subdirs} ${server_list} ${common_commands_list}"
656  tool_makefiles="${tool_makefiles} "`{ for item in ${server_list} ${common_commands_list} ; do echo ${item} | sed 's,^,tools/,; s,$,/Makefile,;' ; done ; } | tr '\n' ' '`
657else
658  AC_MSG_RESULT(no)
659fi
660
661dnl ####################################################################
662dnl #
663dnl # Check whether or not to install all utilities.
664dnl #
665dnl ####################################################################
666
667AC_MSG_CHECKING([whether to install all utilities])
668AC_ARG_WITH(all-tools,
669  [  --with-all-tools        Install all utilities (disabled by default)],
670  [
671    case `echo ${withval} | tr "A-Z" "a-z"` in
672    no)
673      install_all_tools="0"
674      ;;
675    *)
676      install_all_tools="1"
677      ;;
678    esac
679  ],
680  [
681    install_all_tools="0"
682  ]
683)
684if test ${install_everything} -ne 0 -o ${install_all_tools} -ne 0 ; then
685  AC_MSG_RESULT(yes)
686  install_all_tools="1"
687else
688  AC_MSG_RESULT(no)
689fi
690
691dnl ####################################################################
692dnl #
693dnl # Check whether or not to install CFG utilities.
694dnl #
695dnl ####################################################################
696
697AC_MSG_CHECKING([whether to install cfg utilities])
698AC_ARG_WITH(cfg-tools,
699  [  --with-cfg-tools        Install cfg utilities (disabled by default)],
700  [
701    case `echo ${withval} | tr "A-Z" "a-z"` in
702    no)
703      install_cfg="0"
704      ;;
705    *)
706      install_cfg="1"
707      ;;
708    esac
709  ],
710  [
711    if test ${install_all_tools} -eq 0 ; then
712      install_cfg="0"
713    else
714      install_cfg="1"
715    fi
716  ]
717)
718if test ${install_cfg} -ne 0 ; then
719  AC_MSG_RESULT(yes)
720  cfg_list="webjob-cfg-create-list webjob-cfg-delete-list webjob-cfg-get-kvps webjob-cfg-set-kvps webjob-cfg-update-list"
721  doc_subdirs="${doc_subdirs} ${cfg_list}"
722  doc_makefiles="${doc_makefiles} "`{ for item in ${cfg_list} ; do echo ${item} | sed 's,^,doc/,; s,$,/Makefile,;' ; done ; } | tr '\n' ' '`
723  html_files="${html_files} "`{ for item in ${cfg_list} ; do echo ${item} | sed 's/$/.html/;' ; done ; } | tr '\n' ' '`
724  man1_files="${man1_files} "`{ for item in ${cfg_list} ; do echo ${item} | sed 's/$/.1/;' ; done ; } | tr '\n' ' '`
725  tool_subdirs="${tool_subdirs} ${cfg_list}"
726  tool_makefiles="${tool_makefiles} "`{ for item in ${cfg_list} ; do echo ${item} | sed 's,^,tools/,; s,$,/Makefile,;' ; done ; } | tr '\n' ' '`
727  #test_subdirs="${test_subdirs} webjob-cfg-..."
728  #test_makefiles="
729  #  ${test_makefiles}
730  #  tests/webjob-cfg-.../Makefile
731  #  tests/webjob-cfg-.../common/Makefile
732  #  tests/webjob-cfg-.../common/.../Makefile
733  #  tests/webjob-cfg-.../common/.../test_1/Makefile
734  #  "
735  install_lib_perl="1"
736else
737  AC_MSG_RESULT(no)
738fi
739
740dnl ####################################################################
741dnl #
742dnl # Check whether or not to install DSV utilities.
743dnl #
744dnl ####################################################################
745
746AC_MSG_CHECKING([whether to install dsv utilities])
747AC_ARG_WITH(dsv-tools,
748  [  --with-dsv-tools        Install dsv utilities (disabled by default)],
749  [
750    case `echo ${withval} | tr "A-Z" "a-z"` in
751    no)
752      install_dsv="0"
753      ;;
754    *)
755      install_dsv="1"
756      ;;
757    esac
758  ],
759  [
760    if test ${install_all_tools} -eq 0 ; then
761      install_dsv="0"
762    else
763      install_dsv="1"
764    fi
765  ]
766)
767if test ${install_dsv} -ne 0 ; then
768  if test ${use_ssl} -eq 0 ; then
769    AC_MSG_RESULT([OpenSSL support is required, but it has been explicitly disabled (aborting)])
770    exit 1
771  fi
772  AC_MSG_RESULT(yes)
773  doc_makefiles="${doc_makefiles} doc/webjob-dsvtool/Makefile"
774  doc_subdirs="${doc_subdirs} webjob-dsvtool"
775  html_files="${html_files} webjob-dsvtool.html"
776  man1_files="${man1_files} webjob-dsvtool.1"
777  tool_subdirs="${tool_subdirs} webjob-dsvtool"
778  tool_config_subdirs="${tool_config_subdirs} webjob-dsvtool"
779  tool_makefiles="${tool_makefiles} tools/webjob-dsvtool/Makefile"
780  test_subdirs="${test_subdirs} webjob-dsvtool"
781  test_makefiles="
782    ${test_makefiles}
783    tests/webjob-dsvtool/Makefile
784    tests/webjob-dsvtool/common/Makefile
785    tests/webjob-dsvtool/common/sign/Makefile
786    tests/webjob-dsvtool/common/sign/test_1/Makefile
787    tests/webjob-dsvtool/common/verify/Makefile
788    tests/webjob-dsvtool/common/verify/test_1/Makefile
789    "
790else
791  AC_MSG_RESULT(no)
792fi
793
794dnl ####################################################################
795dnl #
796dnl # Check whether or not to install JQD utilities.
797dnl #
798dnl ####################################################################
799
800AC_MSG_CHECKING([whether to install jqd utilities])
801AC_ARG_WITH(jqd-tools,
802  [  --with-jqd-tools        Install jqd utilities (disabled by default)],
803  [
804    case `echo ${withval} | tr "A-Z" "a-z"` in
805    no)
806      install_jqd="0"
807      ;;
808    *)
809      install_jqd="1"
810      ;;
811    esac
812  ],
813  [
814    if test ${install_all_tools} -eq 0 ; then
815      install_jqd="0"
816    else
817      install_jqd="1"
818    fi
819  ]
820)
821if test ${install_jqd} -ne 0 ; then
822  AC_MSG_RESULT(yes)
823  jqd_list="webjob-jqd-change-priority webjob-jqd-change-state webjob-jqd-create-group webjob-jqd-create-job webjob-jqd-create-queue webjob-jqd-delete-group webjob-jqd-delete-job webjob-jqd-delete-queue webjob-jqd-freeze-queue webjob-jqd-list-groups webjob-jqd-list-jobs webjob-jqd-list-members webjob-jqd-list-queues webjob-jqd-update-group"
824  doc_subdirs="${doc_subdirs} ${jqd_list}"
825  doc_makefiles="${doc_makefiles} "`{ for item in ${jqd_list} ; do echo ${item} | sed 's,^,doc/,; s,$,/Makefile,;' ; done ; } | tr '\n' ' '`
826  html_files="${html_files} "`{ for item in ${jqd_list} ; do echo ${item} | sed 's/$/.html/;' ; done ; } | tr '\n' ' '`
827  man1_files="${man1_files} "`{ for item in ${jqd_list} ; do echo ${item} | sed 's/$/.1/;' ; done ; } | tr '\n' ' '`
828  tool_subdirs="${tool_subdirs} ${jqd_list}"
829  tool_makefiles="${tool_makefiles} "`{ for item in ${jqd_list} ; do echo ${item} | sed 's,^,tools/,; s,$,/Makefile,;' ; done ; } | tr '\n' ' '`
830  #test_subdirs="${test_subdirs} webjob-jqd-..."
831  #test_makefiles="
832  #  ${test_makefiles}
833  #  tests/webjob-jqd-.../Makefile
834  #  tests/webjob-jqd-.../common/Makefile
835  #  tests/webjob-jqd-.../common/.../Makefile
836  #  tests/webjob-jqd-.../common/.../test_1/Makefile
837  #  "
838  install_lib_perl="1"
839else
840  AC_MSG_RESULT(no)
841fi
842
843dnl ####################################################################
844dnl #
845dnl # Check whether or not to install MLDBM utilities.
846dnl #
847dnl ####################################################################
848
849AC_MSG_CHECKING([whether to install mldbm utilities])
850AC_ARG_WITH(mldbm-tools,
851  [  --with-mldbm-tools      Install mldbm utilities (disabled by default)],
852  [
853    case `echo ${withval} | tr "A-Z" "a-z"` in
854    no)
855      install_mldbm="0"
856      ;;
857    *)
858      install_mldbm="1"
859      ;;
860    esac
861  ],
862  [
863    if test ${install_all_tools} -eq 0 ; then
864      install_mldbm="0"
865    else
866      install_mldbm="1"
867    fi
868  ]
869)
870if test ${install_mldbm} -ne 0 ; then
871  AC_MSG_RESULT(yes)
872  mldbm_list="webjob-mldbm-create-client webjob-mldbm-create-db webjob-mldbm-create-job webjob-mldbm-delete-client webjob-mldbm-delete-config-key webjob-mldbm-delete-db webjob-mldbm-delete-job webjob-mldbm-delete-job-key webjob-mldbm-dump-db webjob-mldbm-get-config-kvps webjob-mldbm-get-job-kvps webjob-mldbm-get-status webjob-mldbm-list-clients webjob-mldbm-list-jobs webjob-mldbm-load-db webjob-mldbm-set-config-kvps webjob-mldbm-set-job-kvps"
873  doc_subdirs="${doc_subdirs} ${mldbm_list}"
874  doc_makefiles="${doc_makefiles} "`{ for item in ${mldbm_list} ; do echo ${item} | sed 's,^,doc/,; s,$,/Makefile,;' ; done ; } | tr '\n' ' '`
875  html_files="${html_files} "`{ for item in ${mldbm_list} ; do echo ${item} | sed 's/$/.html/;' ; done ; } | tr '\n' ' '`
876  man1_files="${man1_files} "`{ for item in ${mldbm_list} ; do echo ${item} | sed 's/$/.1/;' ; done ; } | tr '\n' ' '`
877  tool_subdirs="${tool_subdirs} ${mldbm_list}"
878  tool_makefiles="${tool_makefiles} "`{ for item in ${mldbm_list} ; do echo ${item} | sed 's,^,tools/,; s,$,/Makefile,;' ; done ; } | tr '\n' ' '`
879  test_subdirs="${test_subdirs} webjob-mldbm-create-db webjob-mldbm-delete-db webjob-mldbm-set-job-kvps"
880  test_makefiles="
881    ${test_makefiles}
882    tests/webjob-mldbm-create-db/Makefile
883    tests/webjob-mldbm-create-db/common/Makefile
884    tests/webjob-mldbm-create-db/common/create/Makefile
885    tests/webjob-mldbm-create-db/common/create/test_1/Makefile
886    tests/webjob-mldbm-delete-db/Makefile
887    tests/webjob-mldbm-delete-db/common/Makefile
888    tests/webjob-mldbm-delete-db/common/delete/Makefile
889    tests/webjob-mldbm-delete-db/common/delete/test_1/Makefile
890    tests/webjob-mldbm-set-job-kvps/Makefile
891    tests/webjob-mldbm-set-job-kvps/common/Makefile
892    tests/webjob-mldbm-set-job-kvps/common/set/Makefile
893    tests/webjob-mldbm-set-job-kvps/common/set/test_1/Makefile
894    "
895  install_lib_perl="1"
896else
897  AC_MSG_RESULT(no)
898fi
899
900dnl ####################################################################
901dnl #
902dnl # Check whether or not to install PaD utilities.
903dnl #
904dnl ####################################################################
905
906AC_MSG_CHECKING([whether to install pad utilities])
907AC_ARG_WITH(pad-tools,
908  [  --with-pad-tools        Install pad utilities (disabled by default)],
909  [
910    case `echo ${withval} | tr "A-Z" "a-z"` in
911    no)
912      install_pad="0"
913      ;;
914    *)
915      install_pad="1"
916      ;;
917    esac
918  ],
919  [
920    if test ${install_all_tools} -eq 0 ; then
921      install_pad="0"
922    else
923      install_pad="1"
924    fi
925  ]
926)
927if test ${install_pad} -ne 0 ; then
928  AC_MSG_RESULT(yes)
929  doc_subdirs="${doc_subdirs} xshar"
930  doc_makefiles="${doc_makefiles} doc/xshar/Makefile"
931  tool_subdirs="${tool_subdirs} xshar ../pad"
932  tool_makefiles="${tool_makefiles} tools/xshar/Makefile pad/Makefile"
933else
934  AC_MSG_RESULT(no)
935fi
936
937dnl ####################################################################
938dnl #
939dnl # Set WWW owner.
940dnl #
941dnl ####################################################################
942
943AC_MSG_CHECKING([WWW owner])
944AC_ARG_WITH(www-owner,
945  [  --with-www-owner=OWNER  Set WWW owner to OWNER (www by default)],
946  [
947    case `echo ${withval} | tr "A-Z" "a-z"` in
948    ""|n|no|y|ye|yes)
949      www_owner=""
950      ;;
951    *)
952      www_owner=${withval}
953      ;;
954    esac
955  ],
956  [
957    www_owner="www"
958  ]
959)
960AC_MSG_RESULT(${www_owner})
961if test ${install_everything} -ne 0 -o ${install_server} -ne 0 ; then
962  if test -z "${www_owner}" ; then
963    AC_MSG_ERROR([*** WWW owner is invalid or missing ... try using --with-www-owner=OWNER])
964  fi
965fi
966AC_SUBST(www_owner)
967
968dnl ####################################################################
969dnl #
970dnl # Set WWW group.
971dnl #
972dnl ####################################################################
973
974AC_MSG_CHECKING([WWW group])
975AC_ARG_WITH(www-group,
976  [  --with-www-group=GROUP  Set WWW group to GROUP (www by default)],
977  [
978    case `echo ${withval} | tr "A-Z" "a-z"` in
979    ""|n|no|y|ye|yes)
980      www_group=""
981      ;;
982    *)
983      www_group=${withval}
984      ;;
985    esac
986  ],
987  [
988    www_group="www"
989  ]
990)
991AC_MSG_RESULT(${www_group})
992if test ${install_everything} -ne 0 -o ${install_server} -ne 0 ; then
993  if test -z "${www_group}" ; then
994    AC_MSG_ERROR([*** WWW group is invalid or missing ... try using --with-www-group=GROUP])
995  fi
996fi
997AC_SUBST(www_group)
998
999dnl ####################################################################
1000dnl #
1001dnl # Set WWW conf directory.
1002dnl #
1003dnl ####################################################################
1004
1005AC_MSG_CHECKING([WWW conf dir])
1006AC_ARG_WITH(www-confdir,
1007  [  --with-www-confdir=DIR  Set WWW conf dir to DIR (/usr/local/apache2/conf by default)],
1008  [
1009    case `echo ${withval} | tr "A-Z" "a-z"` in
1010    ""|n|no|y|ye|yes)
1011      www_confdir=""
1012      ;;
1013    *)
1014      www_confdir=${withval}
1015      ;;
1016    esac
1017  ],
1018  [
1019    www_confdir="/usr/local/apache2/conf"
1020  ]
1021)
1022AC_MSG_RESULT(${www_confdir})
1023if test ${install_everything} -ne 0 -o ${install_server} -ne 0 ; then
1024  if test -z "${www_confdir}" ; then
1025    AC_MSG_ERROR([*** WWW conf dir is invalid or missing ... try using --with-www-confdir=DIR])
1026  fi
1027fi
1028AC_SUBST(www_confdir)
1029
1030dnl ####################################################################
1031dnl #
1032dnl # Set WWW bundled CAs file.
1033dnl #
1034dnl ####################################################################
1035
1036AC_MSG_CHECKING([WWW bundled CAs file])
1037AC_ARG_WITH(www-bundled-cas-file,
1038  [  --with-www-bundled-cas-file=FILE Set WWW bundled CAs file to FILE (WWW_CONF_DIR/ca-bundle.crt by default)],
1039  [
1040    case `echo ${withval} | tr "A-Z" "a-z"` in
1041    ""|n|no|y|ye|yes)
1042      www_bundled_cas_file=""
1043      ;;
1044    *)
1045      www_bundled_cas_file=${withval}
1046      ;;
1047    esac
1048  ],
1049  [
1050    www_bundled_cas_file="${www_confdir}/ca-bundle.crt"
1051  ]
1052)
1053AC_MSG_RESULT(${www_bundled_cas_file})
1054if test ${install_everything} -ne 0 -o ${install_server} -ne 0 ; then
1055  if test -z "${www_bundled_cas_file}" ; then
1056    AC_MSG_ERROR([*** WWW bundled CAs file is invalid or missing ... try using --with-bundled-cas-file=FILE])
1057  fi
1058fi
1059AC_SUBST(www_bundled_cas_file)
1060
1061dnl ####################################################################
1062dnl #
1063dnl # Set WWW public certificate file.
1064dnl #
1065dnl ####################################################################
1066
1067AC_MSG_CHECKING([WWW public certificate file])
1068AC_ARG_WITH(www-public-cert-file,
1069  [  --with-www-public-cert-file=FILE Set WWW public cert file to FILE (WWW_CONF_DIR/server.crt by default)],
1070  [
1071    case `echo ${withval} | tr "A-Z" "a-z"` in
1072    ""|n|no|y|ye|yes)
1073      www_public_cert_file=""
1074      ;;
1075    *)
1076      www_public_cert_file=${withval}
1077      ;;
1078    esac
1079  ],
1080  [
1081    www_public_cert_file="${www_confdir}/server.crt"
1082  ]
1083)
1084AC_MSG_RESULT(${www_public_cert_file})
1085if test ${install_everything} -ne 0 -o ${install_server} -ne 0 ; then
1086  if test -z "${www_public_cert_file}" ; then
1087    AC_MSG_ERROR([*** WWW public certificate file is invalid or missing ... try using --with-public-cert-file=FILE])
1088  fi
1089fi
1090AC_SUBST(www_public_cert_file)
1091
1092dnl ####################################################################
1093dnl #
1094dnl # Set server prefix.
1095dnl #
1096dnl ####################################################################
1097
1098AC_MSG_CHECKING([server prefix])
1099AC_ARG_WITH(server-prefix,
1100  [  --with-server-prefix=PREFIX Set server prefix (PREFIX/var by default)],
1101  [
1102    case `echo ${withval} | tr "A-Z" "a-z"` in
1103    ""|n|no|y|ye|yes)
1104      server_prefix=""
1105      ;;
1106    *)
1107      server_prefix=${withval}
1108      ;;
1109    esac
1110  ],
1111  [
1112    server_prefix=${prefix}
1113  ]
1114)
1115AC_MSG_RESULT(${server_prefix})
1116if test ${install_everything} -ne 0 -o ${install_server} -ne 0 ; then
1117  if test -z "${server_prefix}" ; then
1118    AC_MSG_ERROR([*** server prefix is invalid or missing ... try using --with-server-prefix=PREFIX])
1119  fi
1120fi
1121AC_SUBST(server_prefix)
1122
1123dnl ####################################################################
1124dnl #
1125dnl # Finalize pending variables.
1126dnl #
1127dnl ####################################################################
1128
1129if test ${install_lib_perl} -eq 1 ; then
1130  lib_subdirs="${lib_subdirs} perl"
1131  lib_makefiles="${lib_makefiles} lib/perl/Makefile.PL"
1132fi
1133
1134dnl ####################################################################
1135dnl #
1136dnl # Do substitutions.
1137dnl #
1138dnl ####################################################################
1139
1140AC_SUBST(doc_subdirs)
1141AC_SUBST(etc_subdirs)
1142AC_SUBST(lib_subdirs)
1143AC_SUBST(test_subdirs)
1144AC_SUBST(tool_subdirs)
1145
1146AC_SUBST(html_files)
1147AC_SUBST(man1_files)
1148
1149dnl ####################################################################
1150dnl #
1151dnl # Create Makefiles.
1152dnl #
1153dnl ####################################################################
1154
1155AC_CONFIG_FILES(
1156  [
1157    Makefile
1158    Mk/common.mk
1159    Mk/common-doc-c.mk
1160    Mk/common-doc-perl.mk
1161    Mk/common-doc-sh.mk
1162    Mk/common-etc-conf.mk
1163    Mk/common-src-c.mk
1164    Mk/common-src-cmd.mk
1165    Mk/common-src-perl.mk
1166    Mk/common-src-sh.mk
1167    Mk/common-subdir.mk
1168    Mk/common-tests.mk
1169    ${doc_makefiles}
1170    ${etc_makefiles}
1171    ${lib_makefiles}
1172    src/Makefile
1173    ${test_makefiles}
1174    ${tool_makefiles}
1175  ]
1176)
1177
1178AC_CONFIG_HEADERS(
1179  [src/config.h],
1180  [
1181    for dir in ${tool_config_subdirs} ; do
1182      cp -f src/config.h tools/${dir}/
1183    done
1184  ],
1185  [ tool_config_subdirs="${tool_config_subdirs}" ]
1186)
1187
1188dnl ####################################################################
1189dnl #
1190dnl # FIXME 2008-08-14 mavrik
1191dnl #
1192dnl # For some reason, I was unable to get more than one instance of
1193dnl # AC_CONFIG_COMMANDS to work. If that were possible, I'd have the
1194dnl # MinGW builds run the following:
1195dnl #
1196dnl #   (cd lib/perl && perl config && perl Makefile.PL)
1197dnl #
1198dnl # I tried putting the commands in a variable and passing that to
1199dnl # AC_CONFIG_COMMANDS, but it broke the UNIX builds. For now, the
1200dnl # following will do, but this issue should be revisited.
1201dnl #
1202dnl ####################################################################
1203
1204if test ${install_lib_perl} -eq 1 ; then
1205  case "${target_os}" in
1206  *mingw32*)
1207    lib_subdirs=""
1208    ;;
1209  *)
1210    AC_CONFIG_COMMANDS(
1211      [perl-configure],
1212      [(cd lib/perl && perl Makefile.PL)],
1213      []
1214    )
1215    ;;
1216  esac
1217fi
1218
1219AC_OUTPUT
1220
1221case "${target_os}" in
1222*mingw32*)
1223  echo "Note: To build the Perl modules in this project under MinGW, you must"
1224  echo "      start a command shell (not an MSYS shell) and run the following"
1225  echo "      commands:"
1226  echo
1227  echo "        cmd> cd <project>\lib\perl"
1228  echo "        cmd> perl config"
1229  echo "        cmd> perl Makefile.PL"
1230  echo "        cmd> dmake"
1231  echo "        cmd> dmake test"
1232  echo "        cmd> dmake install"
1233  echo
1234  echo "Note: These steps are only required if you plan to test and/or install"
1235  echo "      the various Perl utilities that are part of the project. You must"
1236  echo "      have ActiveState Perl 5.8.8 build 822 or higher installed. If you"
1237  echo "      have nmake available, you can use that instead of dmake."
1238  echo
1239  echo "Note: Once you have successfully built and installed the Perl modules,"
1240  echo "      you may resume the WebJob build process in the MSYS shell."
1241  ;;
1242esac
1243