1dnl
2dnl File:        configure.in
3dnl Revision:    $Id: 1a56a7f769d2451ea629e5372e5e7907142e6798 $
4dnl Created:     1994/06/18
5dnl Author:      Leif Hedstrom<hedstrom@inf.ethz.ch>
6dnl		 Martin S. Utesch <wstd@hl.siemens.de>
7dnl 		 Peter W. Osel <pwo@GUUG.DE>
8dnl 		 R.K. Owen <rk@owen.sj.ca.us>
9dnl
10dnl Process this file with autoconf to produce a configure script
11dnl You need autoconf 2.52 or better!
12dnl
13dnl ---------------------------------------------------------------------------
14AC_INIT(modules,3.2)
15AC_CONFIG_AUX_DIR(config)
16AM_INIT_AUTOMAKE(1.9.6 foreign dejagnu no-installinfo dist-bzip2)
17AC_CONFIG_SRCDIR([version.c])
18AM_CONFIG_HEADER(config.h)
19AC_PREREQ(2.59)
20
21dnl ---------------------------------------------------------------------------
22dnl Autoheader "templates" (was acconfig.h)
23AH_TOP([
24/*****
25 ** ** Module Header ******************************************************* **
26 ** 									     **
27 **   Modules Revision 3.0						     **
28 **   Providing a flexible user environment				     **
29 ** 									     **
30 **   Description:	config.h.in (generated by autoheader from	     **
31 **			configure.ac)					     **
32 ** 									     **
33 ** ************************************************************************ **
34 ****/
35
36/** ** Copyright *********************************************************** **
37 ** 									     **
38 ** Copyright 1991-1994 by John L. Furlan.                      	     **
39 ** see LICENSE.GPL, which must be provided, for details		     **
40 ** 									     **
41 ** ************************************************************************ **/
42])
43dnl ---------------------------------------------------------------------------
44dnl
45dnl Some special substitution we need:
46dnl
47dnl ---------------------------------------------------------------------------
48dnl Need to know if versioning is asked for before setting certain paths
49dnl --enable-versioning		Use modules versioning 	[DEF]
50dnl --disable-versioning	Without  - " -
51dnl ---------------------------------------------------------------------------
52dnl
53AC_SUBST(WANTS_VERSIONING)
54AC_SUBST(VERSIONING)
55AC_SUBST(NOTVERSIONING)
56AH_TEMPLATE([WANTS_VERSIONING],[
57WANTS_VERSIONING Does the system want to use modules versions])
58AC_ARG_ENABLE(versioning,
59	AC_HELP_STRING([--enable-versioning], [use modules versioning [[yes]]]),
60	if test "$enableval" = "yes"; then
61	    WANTS_VERSIONING=1
62	    AC_DEFINE(WANTS_VERSIONING,1)
63	    VERSIONING=""
64	    NOTVERSIONING="#"
65	else
66	    WANTS_VERSIONING=0
67	    AC_DEFINE(WANTS_VERSIONING,0)
68	    VERSIONING="#"
69	    NOTVERSIONING=""
70	fi, WANTS_VERSIONING=1
71	    AC_DEFINE(WANTS_VERSIONING,1)
72	    VERSIONING=""
73	    NOTVERSIONING="#"
74)
75dnl
76dnl ---------------------------------------------------------------------------
77dnl Get Modules version & date
78dnl ---------------------------------------------------------------------------
79dnl DATE		Module package date
80dnl VERSION		Module package version
81dnl
82AC_SUBST(VERSION)
83AC_SUBST(DATE)
84VERSION='(unknown)'
85VERSION=`sed -n -e 's/^.*version_string.*"\(.*\)";$/\1/p' ${srcdir}/version.c`
86AC_MSG_RESULT([VERSION = $VERSION])
87DATE='(DDMmmYYYY)'
88DATE=`sed -n -e 's/^.*date_string.*"\(.*\)";$/\1/p' ${srcdir}/version.c`
89AC_MSG_RESULT([DATE = $DATE])
90echo "configuring for Modules $VERSION		$DATE"
91dnl ---------------------------------------------------------------------------
92dnl Set PREFIX and related based on WANTS_VERSIONING
93dnl ---------------------------------------------------------------------------
94AC_SUBST(DEFAULTPATH)
95AC_SUBST(BASEPREFIX)
96DEFAULTPATH=default
97AH_TEMPLATE([BASEPREFIX],[ BASEPREFIX: Usually equivalent to /usr/local])
98AH_TEMPLATE([PREFIX],[
99PREFIX: Usually equivalent to /usr/local/Modules[/version_number]])
100AH_TEMPLATE([MODULES_INIT_DIR],[
101MODULES_INIT_DIR: Directory that contains the modules init files.])
102
103if test "$exec_prefix" != "NONE" ; then
104  EXECPREFIX=$exec_prefix
105# can not have versioning if specifying exec-prefix
106  if test "$WANTS_VERSIONING" -eq 1 ; then
107     AC_MSG_ERROR([You can not have versioning if --exec-prefix is specified
108must disable with --disable-versioning ])
109  fi
110fi
111if test "$prefix" != "NONE" ; then
112  if test "$WANTS_VERSIONING" -eq 1 ; then
113    DEFAULTPATH=$prefix/Modules/default
114    NODEFAULTPATH=$prefix/Modules/$VERSION
115    BASEPREFIX=$prefix
116    prefix=$BASEPREFIX/Modules/$VERSION
117    export prefix
118  else
119    DEFAULTPATH=$prefix/Modules
120    NODEFAULTPATH=$prefix/Modules
121    BASEPREFIX=$prefix
122    prefix=$BASEPREFIX/Modules
123    export prefix
124  fi
125  PREFIX=$prefix
126else
127  if test "$WANTS_VERSIONING" -eq 1 ; then
128    DEFAULTPATH=$ac_default_prefix/Modules/default
129    NODEFAULTPATH=$ac_default_prefix/Modules/$VERSION
130    BASEPREFIX=$ac_default_prefix
131    ac_default_prefix=$BASEPREFIX/Modules/$VERSION
132    export ac_default_prefix
133  else
134    DEFAULTPATH=$ac_default_prefix/Modules
135    NODEFAULTPATH=$ac_default_prefix/Modules
136    BASEPREFIX=$ac_default_prefix
137    ac_default_prefix=$BASEPREFIX/Modules
138    export ac_default_prefix
139  fi
140  PREFIX=$ac_default_prefix
141fi
142if test "$exec_prefix" != "NONE" ; then
143  EXECPREFIX=$exec_prefix
144else
145  EXECPREFIX=$PREFIX
146fi
147MODULES_INIT_DIR=$EXECPREFIX/init
148dnl ---------------------------------------------------------------------------
149dnl --enable-use-default        Use PREFIX/default/ in init scripts [DEF]
150dnl --disable-use-default       Use PREFIX/VERSION/ in init scripts
151dnl ---------------------------------------------------------------------------
152AC_DEFINE_UNQUOTED(MODULES_INIT_DIR, "$MODULES_INIT_DIR")
153AC_ARG_ENABLE(use-default,
154	AC_HELP_STRING([--enable-use-default],[use DEFAULTPATH in init scripts [[yes]]]),
155	if test "$enableval" = "no" -o $WANTS_VERSIONING -eq 0; then
156		DEFAULTPATH=$NODEFAULTPATH
157	fi)
158AC_MSG_RESULT([DEFAULTPATH = $DEFAULTPATH])
159AC_MSG_RESULT([BASEPREFIX = $BASEPREFIX])
160AC_MSG_RESULT([PREFIX = $PREFIX])
161AC_MSG_RESULT([EXECPREFIX = $EXECPREFIX])
162AC_DEFINE_UNQUOTED(BASEPREFIX, "$BASEPREFIX")
163AC_DEFINE_UNQUOTED(PREFIX, "$PREFIX")
164export DEFAULTPATH
165export NODEFAULTPATH
166export BASEPREFIX
167export MODULES_INIT_DIR
168dnl ---------------------------------------------------------------------------
169dnl Some standard autoconfig stuff
170dnl Checks for programs
171dnl ---------------------------------------------------------------------------
172AC_PROG_CC
173AC_PROG_CPP
174AC_PROG_GCC_TRADITIONAL
175AC_PROG_INSTALL
176AM_PROG_CC_C_O
177AC_PROG_MAKE_SET
178AC_AIX
179AC_ISC_POSIX
180AC_PATH_PROG([UNAME],[uname],[""])
181dnl ---------------------------------------------------------------------------
182dnl Checks for header files
183dnl ---------------------------------------------------------------------------
184
185AC_HEADER_DIRENT
186AC_HEADER_STDC
187AC_CHECK_HEADERS(string.h memory.h stdlib.h unistd.h termio.h fcntl.h ctype.h \
188	stdarg.h varargs.h syslog.h stdint.h)
189AC_CHECK_HEADERS([sys/ioctl.h sys/termios.h sys/mode.h sys/stat.h sys/param.h \
190		  errno.h assert.h locale.h])
191dnl ---------------------------------------------------------------------------
192dnl Checks for typedefs, structures, and compiler characteristics.
193dnl ---------------------------------------------------------------------------
194AC_C_CONST
195AC_TYPE_UID_T
196AC_TYPE_SIZE_T
197AC_STRUCT_TM
198dnl ---------------------------------------------------------------------------
199dnl Checks for library functions.
200dnl ---------------------------------------------------------------------------
201AC_FUNC_STRCOLL
202AC_CHECK_FUNCS([strdup uname gethostname getdomainname \
203	mktemp tmpnam tempnam \
204	syslog dup2 setlocale])
205dnl ---------------------------------------------------------------------------
206dnl Checks for libraries
207dnl ---------------------------------------------------------------------------
208dnl Solaris 2.x: This requires -lnsl and -lsocket. If AC_PATH_XTRA
209dnl              did not search for these, search them explicitly.
210dnl              MUST be done BEFORE AC_PATH_XTRA!
211dnl ---------------------------------------------------------------------------
212AC_CHECK_LIB(socket, socket)
213AC_CHECK_LIB(nsl, t_accept)
214
215dnl ---------------------------------------------------------------------------
216dnl Check for X11 things
217dnl ---------------------------------------------------------------------------
218AC_PATH_X
219AC_PATH_XTRA
220if test "$no_x" != "yes"; then
221
222	AH_TEMPLATE([HAS_X11LIBS],[
223HAS_X11LIBS:
224This symbol, if defined, indicates that the C program can use X11
225directly.])
226	AC_DEFINE(HAS_X11LIBS)
227	AC_CHECK_LIB(X11, XMaxRequestSize,,,
228		[-I ${ac_x_includes:-.} -L ${ac_x_libraries:-.}])
229dnl	AC_CHECK_LIB(Xmu, XmuGetHostname,,,
230dnl		[-I ${ac_x_includes:-.} -L ${ac_x_libraries:-.}])
231
232fi
233dnl ---------------------------------------------------------------------------
234AH_TEMPLATE([CPPSTDIN],[
235CPPSTDIN:
236This symbol contains the first part of the string which will invoke
237the C preprocessor on the standard input and produce to standard
238output.	 Typical value of "cc -E" or "/lib/cpp".])
239EM_PATH_PROG_SEARCH(_CPPSTDIN, cpp, /lib /usr/lib /usr/lang \
240	/usr/local/lang /usr/ccs/lib, [${CC} -E])
241AC_DEFINE_UNQUOTED(CPPSTDIN, "$_CPPSTDIN")
242dnl
243AH_TEMPLATE([CPPMINUS],[
244CPPMINUS:
245This symbol contains the second part of the string which will invoke
246the C preprocessor on the standard input and produce to standard
247output.  This symbol will have the value "-" if CPPSTDIN needs a minus
248to specify standard input, otherwise the value is "".])
249AC_DEFINE(CPPMINUS, "")
250dnl ---------------------------------------------------------------------------
251AH_TEMPLATE([PHOSTNAME],[
252PHOSTNAME:
253Last resort to get the hostname, if uname() and gethostname()
254are not available.])
255AC_PATH_PROG([_PHOST],[hostname],[""])
256test "$_PHOST" != ""  && AC_DEFINE_UNQUOTED(PHOSTNAME, "$_PHOST")
257AC_PATH_PROG(RUNTEST, runtest, "./not_installed")
258test "$RUNTEST" = "" && echo "Install DEJAGNU and rerun configure if you \
259want to run the testsuite"
260
261dnl
262dnl Here we define some --with & --enable things:
263dnl
264dnl --with-split-size[=<size>]	With split size=<size>		[TEST]
265dnl --without-split-size	Without  - " -
266dnl
267dnl --enable-cache		With directory cache
268dnl --disable-cache		Without  - " -			[DEF]
269dnl
270dnl --enable-shell-funcs	With sh functions		[TEST]
271dnl --disable-shell-funcs	Without  - " -
272dnl
273dnl --enable-shell-alias	With sh aliases			[TEST]
274dnl --disable-shell-alias	Without  - " -
275dnl
276dnl --enable-shell-eval		With shell alias eval
277dnl --disable-shell-eval	Without  - " -			[DEF]
278dnl
279dnl --enable-free		With free() calls
280dnl --disable-free		Without  - " -			[DEF]
281dnl
282dnl --with-debug[=<option>]	Set up debugging level
283dnl --without-debug		Without  - " -			[DEF]
284dnl
285dnl --enable-version-magic      Set .version magic requirement	[DEF]
286dnl --disable-version-magic     .version need not have magic cookie
287dnl
288dnl --enable-beginenv		Use .modulesbeginenv for initial env.	[TEST]
289dnl --disable-beginenv		Do not use .modulesbeginenv
290dnl
291dnl ---------------------------------------------------------------------------
292AH_TEMPLATE([LMSPLIT_SIZE],[
293LMSPLIT_SIZE:
294This symbol, if defined, will force the environment variable
295_LM_FILES_ to be split into smaller "chunks".])
296AC_MSG_CHECKING([if /bin/csh supports large environment variables])
297#
298# test to see how many chars can be set in the C-shell env.var.
299#
300em_split_size_total=0
301if test -x /bin/csh ; then
302cat  >_EMEOF.$$ <<'_EMEOF'
303cat <<'!' | /bin/csh 2> /dev/null | tail -1
304setenv X	""
305setenv ZZZ	"0"
306@ num=2
307while ( $num < 10000 )
308	setenv X	$X$ZZZ
309	echo $num
310	@ num++
311end
312!
313_EMEOF
314em_split_size_total=`/bin/sh _EMEOF.$$`
315rm _EMEOF.$$
316fi
317if test "$cross_compiling" = "yes"; then
318	em_split_size="cross"
319AC_MSG_WARN([You must specify --with-split-size[=<size>]
320when cross compiling ... configure can not guess whether the target system
321C-shell can handle large environment variables or not.])
322elif test $em_split_size_total -gt 4000 ; then
323	em_split_size="no"
324	AC_MSG_RESULT([yes - $em_split_size_total > 4000])
325else
326	# set split-size a little less
327	em_split_size=`expr $em_split_size_total - 20`
328	if test $em_split_size -lt 0 ; then
329		em_split_size=1000
330	fi
331	AC_MSG_RESULT([no - $em_split_size_total < 4000 - splitting at $em_split_size])
332fi
333AC_ARG_WITH(split-size,
334	AC_HELP_STRING([--with-split-size[=<size>]],[use split size=<size> [[test]]]),
335	if test "${withval+set}" = "set" -a "$withval" != "no"; then
336		if test "$withval" = "yes"; then
337			withval=1000
338		fi
339		AC_MSG_NOTICE([csh split-size set to $withval])
340		AC_DEFINE_UNQUOTED(LMSPLIT_SIZE, ${withval})
341	else
342		AC_MSG_NOTICE([csh split-size not set])
343	fi,
344	if test "$em_split_size" != "no" -a "$em_split_size" != "cross" ; then
345		AC_MSG_NOTICE([csh split-size set to $em_split_size])
346		AC_DEFINE_UNQUOTED(LMSPLIT_SIZE, ${em_split_size})
347	else
348		AC_MSG_NOTICE([csh split-size not set])
349	fi)
350dnl ---------------------------------------------------------------------------
351dnl --with-static[=<option>]	With static linking
352dnl --without-static		Without  - " -		[DEF]
353dnl STATIC		Link the binary 'static'
354dnl
355AC_SUBST(STATIC)
356dnl
357AC_ARG_WITH(static,
358	AC_HELP_STRING([--with-static[[=<option>]]],[use static linking [[no]]]),
359	EM_SET_STATIC(STATIC, $withval))
360
361dnl ---------------------------------------------------------------------------
362AH_TEMPLATE([HAS_BOURNE_FUNCS],[
363HAS_BOURNE_FUNCS:
364This symbol, if defined, indicates that the Bourne shell can define aliases
365as shell functions.])
366AC_MSG_CHECKING([if /bin/sh supports functions])
367
368if test "$cross_compiling" = "yes"; then
369	em_bourne_funcs="cross"
370AC_MSG_WARN([You must specify --enable-shell-funcs or --disable-shell-funcs
371when cross compiling ... configure can not guess whether the target system
372Bourne shell can handle shell functions or not.])
373elif (
374	cat <<_EMEOF | /bin/sh 2> /dev/null
375if (xxx() { ls; }) > /dev/null 2>&1; then
376	(exit 0); exit 0
377else
378	(exit 42); exit 42
379fi
380_EMEOF
381
382	if test $? = 0 ; then
383		(exit 0); exit 0
384	else
385		(exit 42); exit 42
386	fi
387) ; then
388	em_bourne_funcs="yes"
389else
390	em_bourne_funcs="no"
391fi
392AC_MSG_RESULT([$em_bourne_funcs])
393AC_ARG_ENABLE(shell-funcs,
394	AC_HELP_STRING([--enable-shell-funcs],[use sh functions [[test]]]),
395	if test "$enableval" = "yes" ; then
396	    AC_DEFINE(HAS_BOURNE_FUNCS)
397	fi,
398	if test "$em_bourne_funcs" = "cross" ; then
399AC_MSG_ERROR([You did not --enable-shell-funcs or --disable-shell-funcs
400when cross compiling ... aborting!])
401	elif test "$em_bourne_funcs" = "yes" ; then
402	    AC_DEFINE(HAS_BOURNE_FUNCS)
403	fi)
404dnl ---------------------------------------------------------------------------
405AH_TEMPLATE([HAS_BOURNE_ALIAS],[
406HAS_BOURNE_ALIAS:
407This symbol, if defined, indicates that the Bourne shell can define aliases
408(in other words not a "true" Bourne shell).])
409AC_MSG_CHECKING([if /bin/sh supports aliases])
410
411if test "$cross_compiling" = "yes"; then
412	em_bourne_alias="cross"
413AC_MSG_WARN([You must specify --enable-shell-alias or --disable-shell-alias
414when cross compiling ... configure can not guess whether the target system
415Bourne shell can handle shell aliases or not.])
416elif (
417	cat <<_EMEOF | /bin/sh 2> /dev/null
418if (alias xxx='ls') > /dev/null 2>&1; then
419	(exit 0); exit 0
420else
421	(exit 42); exit 42
422fi
423_EMEOF
424
425	if test $? = 0 ; then
426		(exit 0); exit 0
427	else
428		(exit 42); exit 42
429	fi
430) ; then
431	em_bourne_alias="yes"
432else
433	em_bourne_alias="no"
434fi
435AC_MSG_RESULT([$em_bourne_alias])
436AC_ARG_ENABLE(shell-alias,
437	AC_HELP_STRING([--enable-shell-alias],[use sh aliases [[test]]]),
438	if test "$enableval" = "yes" ; then
439	    AC_DEFINE(HAS_BOURNE_ALIAS)
440	fi,
441	if test "$em_bourne_alias" = "cross" ; then
442AC_MSG_ERROR([You did not --enable-shell-alias or --disable-shell-alias
443when cross compiling ... aborting!])
444	elif test "$em_bourne_alias" = "yes" ; then
445	    AC_DEFINE(HAS_BOURNE_ALIAS)
446	fi)
447dnl ---------------------------------------------------------------------------
448AH_TEMPLATE([EVAL_ALIAS],[
449EVAL_ALIAS:
450This symbol, if defined, indicates that Modules should ask the shell
451to evaluate aliases via stdout like other environment changes instead
452of opening a file and then asking the shell to source the file and
453then remove it.])
454AC_ARG_ENABLE(shell-eval,
455	AC_HELP_STRING([--enable-shell-eval],[use shell alias eval [[yes]]]),
456	if test "$enableval" = "yes"; then
457	    AC_DEFINE(EVAL_ALIAS)
458	fi, AC_DEFINE(EVAL_ALIAS))
459dnl ---------------------------------------------------------------------------
460AH_TEMPLATE([USE_FREE],[
461USE_FREE:
462By default, Modules will not call free() for any dynamic data. This
463define enables these calls.])
464AC_ARG_ENABLE(free,
465	AC_HELP_STRING([--enable-free],[use free() calls [[no]]]),
466	if test "$enableval" = "yes"; then
467	    AC_DEFINE(USE_FREE)
468	fi)
469dnl ---------------------------------------------------------------------------
470AH_TEMPLATE([CACHE_AVAIL],[
471CACHE_AVAIL:
472This symbol, if defined, indicates that Modules should cache the
473directories in MODULEPATH when doing an avail.])
474AC_ARG_ENABLE(cache,
475	AC_HELP_STRING([--enable-cache],[use directory cache [[no]]]),
476	if test "$enableval" = "yes"; then
477	    AC_DEFINE(CACHE_AVAIL)
478	fi)
479dnl ---------------------------------------------------------------------------
480AH_TEMPLATE([CACHE_UMASK],[
481CACHE_UMASK:
482This symbol, if defined, is used as the umask for creating
483cachefiles for the module avail command.])
484AC_ARG_WITH(cache-umask,
485	AC_HELP_STRING([--with-cache-umask=<umask>],[use cache files umask=<umask> [[000]]]),
486	if test "$withval" != "no"; then
487	    test "$withval" = "yes" && withval=0
488	    AC_DEFINE_UNQUOTED(CACHE_UMASK, ${withval})
489	fi)
490dnl ---------------------------------------------------------------------------
491AH_TEMPLATE([WITH_DEBUG_INFO],[WITH_DEBUG_INFO: Debug info level if defined])
492AC_ARG_WITH(debug,
493	AC_HELP_STRING([--with-debug=<value>],[set debugging level <value> [[no]]]),
494	if test "$withval" != "no"; then
495		test "$withval" = "yes" && withval="1"
496		AC_DEFINE_UNQUOTED(WITH_DEBUG_INFO, ${withval})
497	fi)
498dnl ---------------------------------------------------------------------------
499AH_TEMPLATE([VERSION_MAGIC],[
500VERSION_MAGIC:
501By default, .version files will be required to have the modulefile
502magic cookie to be valid, else an error message will be printed out.])
503AC_ARG_ENABLE(version-magic,
504	AC_HELP_STRING([--enable-version-magic],[set .version magic requirement  [[yes]]]),
505	if test "$enableval" != "no"; then
506		AC_DEFINE(VERSION_MAGIC,1)
507	else
508		AC_DEFINE(VERSION_MAGIC,0)
509	fi, AC_DEFINE(VERSION_MAGIC,1))
510dnl ---------------------------------------------------------------------------
511AH_TEMPLATE([BEGINENV],[
512BEGINENV:
513Modules can save the initial user environment in the .modulesbeginenv
514when the first module is loaded.  If enabled then the module update
515subcommand will work.  If set to test, then this essentially enables
516this feature, but will only work if the MODULESBEGINENV env.var is
517set to a file name (e.g. '$HOME/.modulesbeginenv.$$'- modules will
518do one-level of variable expansion.)])
519AC_ARG_ENABLE(beginenv,
520	AC_HELP_STRING([--enable-beginenv],[use .modulesbeginenv for initial env [[test]]]),
521	if test "$enableval" = "yes"; then
522		AC_DEFINE(BEGINENV,1)
523	elif test "$enableval" = "test"; then
524		AC_DEFINE(BEGINENV,99)
525	fi, AC_DEFINE(BEGINENV,99))
526dnl ---------------------------------------------------------------------------
527dnl  Logging
528dnl  The following option allow switching logging on and off
529dnl  and provide a possibility to set up the default facilities
530dnl ---------------------------------------------------------------------------
531dnl WITH_LOGGING	Whether syslogging is enabled
532dnl
533AC_SUBST(WITH_LOGGING)
534AH_TEMPLATE([WITH_LOGGING],[WITH_LOGGING: Syslog logging and facilities])
535AH_TEMPLATE([WITH_LOG_DIR],[])
536AH_TEMPLATE([WITH_LOG_FACILITY_VERBOSE],[])
537AH_TEMPLATE([WITH_LOG_FACILITY_INFO],[])
538AH_TEMPLATE([WITH_LOG_FACILITY_DEBUG],[])
539AH_TEMPLATE([WITH_LOG_FACILITY_TRACE],[])
540AH_TEMPLATE([WITH_LOG_FACILITY_WARN],[])
541AH_TEMPLATE([WITH_LOG_FACILITY_PROB],[])
542AH_TEMPLATE([WITH_LOG_FACILITY_ERROR],[])
543AH_TEMPLATE([WITH_LOG_FACILITY_FATAL],[])
544AH_TEMPLATE([WITH_LOG_FACILITY_PANIC],[])
545WITH_LOGGING=0
546AC_ARG_ENABLE(logging,
547	AC_HELP_STRING([--enable-logging],[turn logging on                 [[no]]]),
548	if test "$enableval" = "yes"; then
549		AC_DEFINE(WITH_LOGGING)
550		WITH_LOGGING=1
551	fi)
552AC_ARG_WITH(log-dir,
553	AC_HELP_STRING([--with-log-dir=<value>],[select an alternate log dir.  [[no]]]),
554	if test "$withval" != "no"; then
555		test "$withval" = "yes" && withval="/tmp"
556		AC_DEFINE_UNQUOTED(WITH_LOG_DIR, "$withval")
557	fi)
558AC_ARG_WITH(log-facility-verbose,
559	AC_HELP_STRING([--with-log-facility-verbose[=<facility>]],[Log facility    [[stderr]]]),
560	if test "$withval" != "no"; then
561		test "$withval" = "yes" && withval="stderr"
562		AC_DEFINE_UNQUOTED(WITH_LOG_FACILITY_VERBOSE, "$withval")
563	fi)
564AC_ARG_WITH(log-facility-info,
565	AC_HELP_STRING([--with-log-facility-info[=<facility>]],[Log facility    [[local7.notice]]]),
566	if test "$withval" != "no"; then
567		test "$withval" = "yes" && withval="local7.notice"
568		AC_DEFINE_UNQUOTED(WITH_LOG_FACILITY_INFO, "$withval")
569	fi)
570AC_ARG_WITH(log-facility-debug,
571	AC_HELP_STRING([--with-log-facility-debug[=<facility>]],[Log facility    [[local7.notice]]]),
572	if test "$withval" != "no"; then
573		test "$withval" = "yes" && withval="local7.notice"
574		AC_DEFINE_UNQUOTED(WITH_LOG_FACILITY_DEBUG, "$withval")
575	fi)
576AC_ARG_WITH(log-facility-trace,
577	AC_HELP_STRING([--with-log-facility-trace[=<facility>]],[Log facility    [[local7.notice]]]),
578	if test "$withval" != "no"; then
579		test "$withval" = "yes" && withval="local7.notice"
580		AC_DEFINE_UNQUOTED(WITH_LOG_FACILITY_TRACE, "$withval")
581	fi)
582AC_ARG_WITH(log-facility-warn,
583	AC_HELP_STRING([--with-log-facility-warn[=<facility>]],[Log facility    [[local7.warning]]]),
584	if test "$withval" != "no"; then
585		test "$withval" = "yes" && withval="local7.warning"
586		AC_DEFINE_UNQUOTED(WITH_LOG_FACILITY_WARN, "$withval")
587	fi)
588AC_ARG_WITH(log-facility-problem,
589	AC_HELP_STRING([--with-log-facility-problem[=<facility>]],[Log facility    [[local7.error]]]),
590	if test "$withval" != "no"; then
591		test "$withval" = "yes" && withval="local7.error"
592		AC_DEFINE_UNQUOTED(WITH_LOG_FACILITY_PROB, "$withval")
593	fi)
594AC_ARG_WITH(log-facility-error,
595	AC_HELP_STRING([--with-log-facility-error[=<facility>]],[Log facility    [[local7.error]]]),
596	if test "$withval" != "no"; then
597		test "$withval" = "yes" && withval="local7.error"
598		AC_DEFINE_UNQUOTED(WITH_LOG_FACILITY_ERROR, "$withval")
599	fi)
600AC_ARG_WITH(log-facility-fatal,
601	AC_HELP_STRING([--with-log-facility-fatal[=<facility>]],[Log facility    [[local7.error]]]),
602	if test "$withval" != "no"; then
603		test "$withval" = "yes" && withval="local7.error"
604		AC_DEFINE_UNQUOTED(WITH_LOG_FACILITY_FATAL, "$withval")
605	fi)
606AC_ARG_WITH(log-facility-panic,
607	AC_HELP_STRING([--with-log-facility-panic[=<facility>]],[Log facility    [[local7.error]]]),
608	if test "$withval" != "no"; then
609		test "$withval" = "yes" && withval="local7.error"
610		AC_DEFINE_UNQUOTED(WITH_LOG_FACILITY_PANIC, "$withval")
611	fi)
612dnl ---------------------------------------------------------------------------
613dnl  Tracing
614dnl  The following option allow switching tracing on and off on a
615dnl  per module command basis
616dnl ---------------------------------------------------------------------------
617AH_TEMPLATE([WITH_TRACE_LOAD],[Tracking])
618AH_TEMPLATE([WITH_TRACE_UNLOAD],[])
619AH_TEMPLATE([WITH_TRACE_SWITCH],[])
620AH_TEMPLATE([WITH_TRACE_DISP],[])
621AH_TEMPLATE([WITH_TRACE_LIST],[])
622AH_TEMPLATE([WITH_TRACE_AVAIL],[])
623AH_TEMPLATE([WITH_TRACE_HELP],[])
624AH_TEMPLATE([WITH_TRACE_INIT],[])
625AH_TEMPLATE([WITH_TRACE_USE],[])
626AH_TEMPLATE([WITH_TRACE_UNUSE],[])
627AH_TEMPLATE([WITH_TRACE_UPDATE],[])
628AH_TEMPLATE([WITH_TRACE_PURGE],[])
629AH_TEMPLATE([WITH_TRACE_CLEAR],[])
630AH_TEMPLATE([WITH_TRACE_WHATIS],[])
631AH_TEMPLATE([WITH_TRACE_APROPOS],[])
632
633AC_ARG_WITH(trace-load,
634	AC_HELP_STRING([--with-trace-load=<value>],[specify a pattern for trace   [[no]]]),
635	if test "$withval" != "no"; then
636		if test "$withval" = "yes"; then
637			AC_DEFINE_UNQUOTED(WITH_TRACE_LOAD, _all_on)
638		else
639			AC_DEFINE_UNQUOTED(WITH_TRACE_LOAD, "$withval")
640		fi
641	fi)
642AC_ARG_WITH(trace-unload,
643	AC_HELP_STRING([--with-trace-unload=<value>],[specify a pattern for trace   [[no]]]),
644	if test "$withval" != "no"; then
645		if test "$withval" = "yes"; then
646			AC_DEFINE_UNQUOTED(WITH_TRACE_UNLOAD, _all_on)
647		else
648			AC_DEFINE_UNQUOTED(WITH_TRACE_UNLOAD, "$withval")
649		fi
650	fi)
651AC_ARG_WITH(trace-switch,
652	AC_HELP_STRING([--with-trace-switch=<value>],[specify a pattern for trace   [[no]]]),
653	if test "$withval" != "no"; then
654		if test "$withval" = "yes"; then
655			AC_DEFINE_UNQUOTED(WITH_TRACE_SWITCH, _all_on)
656		else
657			AC_DEFINE_UNQUOTED(WITH_TRACE_SWITCH, "$withval")
658		fi
659	fi)
660AC_ARG_WITH(trace-disp,
661	AC_HELP_STRING([--with-trace-disp=<value>],[specify a pattern for trace   [[no]]]),
662	if test "$withval" != "no"; then
663		if test "$withval" = "yes"; then
664			AC_DEFINE_UNQUOTED(WITH_TRACE_DISP, _all_on)
665		else
666			AC_DEFINE_UNQUOTED(WITH_TRACE_DISP, "$withval")
667		fi
668	fi)
669AC_ARG_WITH(trace-list,
670	AC_HELP_STRING([--with-trace-list=<value>],[specify a pattern for trace   [[no]]]),
671	if test "$withval" != "no"; then
672		if test "$withval" = "yes"; then
673			AC_DEFINE_UNQUOTED(WITH_TRACE_LIST, _all_on)
674		else
675			AC_DEFINE_UNQUOTED(WITH_TRACE_LIST, "$withval")
676		fi
677	fi)
678AC_ARG_WITH(trace-avail,
679	AC_HELP_STRING([--with-trace-avail=<value>],[specify a pattern for trace   [[no]]]),
680	if test "$withval" != "no"; then
681		if test "$withval" = "yes"; then
682			AC_DEFINE_UNQUOTED(WITH_TRACE_AVAIL, _all_on)
683		else
684			AC_DEFINE_UNQUOTED(WITH_TRACE_AVAIL, "$withval")
685		fi
686	fi)
687AC_ARG_WITH(trace-help,
688	AC_HELP_STRING([--with-trace-help=<value>],[specify a pattern for trace   [[no]]]),
689	if test "$withval" != "no"; then
690		if test "$withval" = "yes"; then
691			AC_DEFINE_UNQUOTED(WITH_TRACE_HELP, _all_on)
692		else
693			AC_DEFINE_UNQUOTED(WITH_TRACE_HELP, "$withval")
694		fi
695	fi)
696AC_ARG_WITH(trace-init,
697	AC_HELP_STRING([--with-trace-init=<value>],[specify a pattern for trace   [[no]]]),
698	if test "$withval" != "no"; then
699		if test "$withval" = "yes"; then
700			AC_DEFINE_UNQUOTED(WITH_TRACE_INIT, _all_on)
701		else
702			AC_DEFINE_UNQUOTED(WITH_TRACE_INIT, "$withval")
703		fi
704	fi)
705AC_ARG_WITH(trace-use,
706	AC_HELP_STRING([--with-trace-use=<value>],[specify a pattern for trace   [[no]]]),
707	if test "$withval" != "no"; then
708		if test "$withval" = "yes"; then
709			AC_DEFINE_UNQUOTED(WITH_TRACE_USE, _all_on)
710		else
711			AC_DEFINE_UNQUOTED(WITH_TRACE_USE, "$withval")
712		fi
713	fi)
714AC_ARG_WITH(trace-unuse,
715	AC_HELP_STRING([--with-trace-unuse=<value>],[specify a pattern for trace   [[no]]]),
716	if test "$withval" != "no"; then
717		if test "$withval" = "yes"; then
718			AC_DEFINE_UNQUOTED(WITH_TRACE_UNUSE, _all_on)
719		else
720			AC_DEFINE_UNQUOTED(WITH_TRACE_UNUSE, "$withval")
721		fi
722	fi)
723AC_ARG_WITH(trace-update,
724	AC_HELP_STRING([--with-trace-update=<value>],[specify a pattern for trace   [[no]]]),
725	if test "$withval" != "no"; then
726		if test "$withval" = "yes"; then
727			AC_DEFINE_UNQUOTED(WITH_TRACE_UPDATE, _all_on)
728		else
729			AC_DEFINE_UNQUOTED(WITH_TRACE_UPDATE, "$withval")
730		fi
731	fi)
732AC_ARG_WITH(trace-purge,
733	AC_HELP_STRING([--with-trace-purge=<value>],[specify a pattern for trace   [[no]]]),
734	if test "$withval" != "no"; then
735		if test "$withval" = "yes"; then
736			AC_DEFINE_UNQUOTED(WITH_TRACE_PURGE, _all_on)
737		else
738			AC_DEFINE_UNQUOTED(WITH_TRACE_PURGE, "$withval")
739		fi
740	fi)
741AC_ARG_WITH(trace-clear,
742	AC_HELP_STRING([--with-trace-clear=<value>],[specify a pattern for trace   [[no]]]),
743	if test "$withval" != "no"; then
744		if test "$withval" = "yes"; then
745			AC_DEFINE_UNQUOTED(WITH_TRACE_CLEAR, _all_on)
746		else
747			AC_DEFINE_UNQUOTED(WITH_TRACE_CLEAR, "$withval")
748		fi
749	fi)
750AC_ARG_WITH(trace-whatis,
751	AC_HELP_STRING([--with-trace-whatis=<value>],[specify a pattern for trace   [[no]]]),
752	if test "$withval" != "no"; then
753		if test "$withval" = "yes"; then
754			AC_DEFINE_UNQUOTED(WITH_TRACE_WHATIS, _all_on)
755		else
756			AC_DEFINE_UNQUOTED(WITH_TRACE_WHATIS, "$withval")
757		fi
758	fi)
759AC_ARG_WITH(trace-apropos,
760	AC_HELP_STRING([--with-trace-apropos=<value>],[specify a pattern for trace  [[no]]]),
761	if test "$withval" != "no"; then
762		if test "$withval" = "yes"; then
763			AC_DEFINE_UNQUOTED(WITH_TRACE_APROPOS, _all_on)
764		else
765			AC_DEFINE_UNQUOTED(WITH_TRACE_APROPOS, "$withval")
766		fi
767	fi)
768dnl ---------------------------------------------------------------------------
769dnl Find libraries, functions and special programs
770dnl	The dynamic loader library should only be probed for, if
771dnl	static linking is not switched on!
772dnl ---------------------------------------------------------------------------
773AC_CHECK_LIB(m, log)
774if test "${STATIC-foobar}" = "foobar"; then
775    AC_CHECK_LIB(dl, dlopen)
776fi
777
778dnl
779dnl--------------------------------------------------------------------
780dnl Load the tclConfig.sh file
781dnl--------------------------------------------------------------------
782
783SC_PATH_TCLCONFIG
784SC_LOAD_TCLCONFIG
785EM_SET_TCL
786EM_CHECK_TCL
787
788dnl--------------------------------------------------------------------
789dnl Load the tclxConfig.sh file
790dnl search for tclx after tcl, not before, to benefit from tcl_includes
791dnl--------------------------------------------------------------------
792
793EM_PATH_TCLXCONFIG
794EM_LOAD_TCLXCONFIG
795dnl Skip TclX fine tuned selection if TclX not wanted
796if test x"$with_tclxconfig" != x"no" ; then
797    EM_SET_TCLX
798    EM_CHECK_TCLX
799fi
800if test x"$no_tclx" != x"true"; then
801	AH_TEMPLATE([HAS_TCLXLIBS],[
802HAS_TCLXLIBS:
803This symbol, if defined, indicates that Modules should support
804extended TCL (tclX) commands.])
805	AC_DEFINE(HAS_TCLXLIBS)
806fi
807
808dnl --------------------------------------------------------------------
809dnl Find Python interpreter
810dnl --------------------------------------------------------------------
811AC_ARG_WITH(python,
812	AC_HELP_STRING([--with-python=<bin>],[Python interpreter command to use [[python]]]),
813	[python="$withval"], [python="python"])
814# specified python is full path bin or uses env command
815if test x"$python" = x"/usr/bin/env python" || test -x "$python" ; then
816    AC_MSG_CHECKING([for $python])
817    PYTHON="$python"
818    AC_MSG_RESULT([yes])
819# otherwise search for python bin in PATH
820else
821    AC_PATH_PROG([PYTHON],[$python],[])
822fi
823dnl Python is mandatory if installing from git repository to build ChangeLog
824if test -z "$PYTHON" ; then
825    if test -e ChangeLog ; then
826        PYTHON="/usr/bin/env python"
827    else
828        AC_MSG_ERROR([Python command cannot be found, whereas required to build ChangeLog.])
829    fi
830fi
831
832dnl ---------------------------------------------------------------------------
833dnl
834dnl   --with-module-path
835dnl   --with-version-path
836dnl   --with-tmp-dir
837dnl   --with-autoload-path
838dnl
839dnl ---------------------------------------------------------------------------
840dnl MODULEPATH		The modulepath we want
841dnl
842AC_SUBST(MODULEPATH)
843AH_TEMPLATE([MODULEPATH],[
844MODULEPATH: Directory that contains all the system module files])
845AC_ARG_WITH(module-path,
846	AC_HELP_STRING([--with-module-path=<path>],[use module path=<path> [[PREFIX/Modules/modulefiles]]]),
847	MODULEPATH="$withval"
848	AC_MSG_RESULT([MODULEPATH = $with_module_path])
849	AC_DEFINE_UNQUOTED(MODULEPATH, "$withval")
850	,
851dnl 	AC_MSG_WARN([if using '--with-module-path': need to specify a path!])
852	withval="$BASEPREFIX/Modules/modulefiles"
853	AC_MSG_WARN([will use MODULEPATH=$withval : rerun configure using --with-module-path to override default])
854	MODULEPATH="$withval"
855	AC_DEFINE_UNQUOTED(MODULEPATH, "$withval"))
856dnl ---------------------------------------------------------------------------
857dnl VERSIONPATH		The modulepath different versions of modules
858dnl
859AC_SUBST(VERSIONPATH)
860AH_TEMPLATE([VERSIONPATH],[
861VERSIONPATH: Directory that contains the env.modules version files.])
862AC_ARG_WITH(version-path,
863	AC_HELP_STRING([--with-version-path=<path>],[use version path=<path> [[PREFIX/Modules/versions]]]),
864	VERSIONPATH="$withval"
865	AC_MSG_RESULT([VERSIONPATH = $with_version_path])
866	AC_DEFINE_UNQUOTED(VERSIONPATH, "$withval")
867	,
868if test "$WANTS_VERSIONING" -eq 1 ; then
869dnl AC_MSG_WARN([if using '--with-version-path': need to specify a path!])
870	withval="$BASEPREFIX/Modules/versions"
871	AC_MSG_WARN([will use VERSIONPATH=$withval : rerun configure using --with-version-path to override default])
872	VERSIONPATH="$withval"
873	AC_DEFINE_UNQUOTED(VERSIONPATH, "$withval")
874fi)
875dnl ---------------------------------------------------------------------------
876AH_TEMPLATE([TMP_DIR],[TMP_DIR: tmp directory name])
877AC_ARG_WITH(tmp-dir,
878	AC_HELP_STRING([--with-tmp-dir=<dir>],[use <dir> as a temporary dir [[/tmp]]]),
879        if test ! -d $withval ; then
880           AC_MSG_ERROR([tmp dir $withval does not exist])
881        fi
882	AC_DEFINE_UNQUOTED(TMP_DIR, "$withval")
883	AC_MSG_RESULT([TMP_DIR = $withval]),
884        if test -d "/tmp" ; then
885           AC_DEFINE_UNQUOTED(TMP_DIR, "/tmp")
886        elif test -d "/var/tmp" ; then
887           AC_DEFINE_UNQUOTED(TMP_DIR, "/var/tmp")
888        fi
889	)
890dnl ---------------------------------------------------------------------------
891AH_TEMPLATE([DEFAULTMANPATH],[DEFAULTMANPATH: default man path])
892AC_ARG_WITH(man-path,
893	AC_HELP_STRING([--with-man-path=<dir>],[use <dir> for the default MANPATH [[/usr/man:/usr/share/man]]]),
894	AC_DEFINE_UNQUOTED(DEFAULTMANPATH, "$withval")
895	AC_MSG_RESULT([DEFAULTMANPATH = $withval]),
896        if test -d "/usr/man" ; then
897           withval="/usr/man"
898           if test -d "/usr/share/man" ; then
899               withval="$withval:/usr/share/man"
900	   fi
901        elif test -d "/usr/share/man" ; then
902           withval="/usr/share/man"
903        fi
904        AC_DEFINE_UNQUOTED(DEFAULTMANPATH, "$withval")
905	)
906	AC_MSG_RESULT([DEFAULTMANPATH = $withval])
907dnl ---------------------------------------------------------------------------
908dnl AUTOLOADPATH	directories where Tcl will search for libraries to load
909dnl
910AC_SUBST(AUTOLOADPATH)
911AH_TEMPLATE([AUTOLOADPATH],[
912AUTOLOADPATH:
913This symbol, if defined, is the "default" path of directories
914Tcl will look for functions to autoload.  It is space separated!])
915AC_ARG_WITH(autoload-path,
916	AC_HELP_STRING([--with-autoload-path=<path>],[use autoload path=<path> [[PREFIX/lib/tcl]]]),
917	if test "$withval" = "no" || test "$withval" = "yes"; then
918		if test "$prefix" != "NONE" ; then
919			withval="$prefix/lib/tcl"
920		else
921			withval="$ac_default_prefix/lib/tcl"
922		fi
923	fi
924	AUTOLOADPATH="$withval"
925	AC_DEFINE_UNQUOTED(AUTOLOADPATH, "$withval"))
926dnl ---------------------------------------------------------------------------
927dnl   --with-etc-path
928dnl   --with-skel-path
929dnl   --with-dot-ext
930dnl ---------------------------------------------------------------------------
931dnl ETCPATH		Where to find the /etc/"login" files
932dnl
933AC_SUBST(ETCPATH)
934AC_ARG_WITH(etc-path,
935	AC_HELP_STRING([--with-etc-path=<path>],[use etc path=<path> [[/etc]]]),
936	[if test "$withval" = "no" || test "$withval" = "yes"; then
937		AC_MSG_WARN(
938	[if using '--with-etc-path': need to specify a path! Using /etc])
939		withval="/etc"
940	fi
941	ETCPATH="$withval"]
942	,
943	ETCPATH="/etc")
944dnl ---------------------------------------------------------------------------
945dnl SKELPATH		Where to find the $HOME/dot file skeletons
946dnl
947AC_SUBST(SKELPATH)
948AC_ARG_WITH(skel-path,
949	AC_HELP_STRING([--with-skel-path=<path>],[use skel path=<path> [[/etc/skel]]]),
950	if test "$withval" = "no" || test "$withval" = "yes"; then
951	AC_MSG_WARN([if using '--with-skel-path': need to specify a path! Using /etc/skel])
952		withval="/etc/skel"
953	fi
954	SKELPATH="$withval"
955	,
956	SKELPATH="/etc/skel")
957dnl ---------------------------------------------------------------------------
958dnl DOT_EXT		Whether to use a dot-file extension
959dnl EXTDIR		Which add.* script to include
960dnl
961AC_SUBST(DOT_EXT)
962AC_SUBST(EXTDIR)
963AH_TEMPLATE([DOT_EXT],[
964DOT_EXT:
965Set this to some extension value (e.g. .ext) to be appended onto
966each shell dot-file name in the list for each shell for processing
967the "module init*" commands.  For example - C-shell: .cshrc.ext,
968.login.ext.])
969AC_ARG_WITH(dot-ext,
970	AC_HELP_STRING([--with-dot-ext=<.ext>],[append <.ext> (default=.ext) to shell dot files [[no]]]),
971	if test "$withval" != "no"; then
972		test "$withval" = "yes" && withval=".ext"
973		AC_DEFINE_UNQUOTED(DOT_EXT, "$withval")
974		EXTDIR="ext"
975	else
976		AC_DEFINE(DOT_EXT, "")
977		EXTDIR="etc"
978	fi,
979	AC_DEFINE(DOT_EXT, "")
980	EXTDIR="etc"
981)
982dnl ---------------------------------------------------------------------------
983dnl helpful configure --help comments
984m4_divert_once([HELP_WITH],[[
985
986The default value or disposition is listed in the square brackets above.
987Beware of new defaults for use-cache, beginenv.
988
989Depending on the above configuration options  the files are approximately
990placed in the following directory structure :
991PREFIX/Modules/($MODULES_VERSION/ if modules-versioning)
992	bin/
993	init/
994	man/
995		man1/
996		man4/
997	modulefiles/
998PREFIX/Modules/
999	modulefiles/
1000	(versions/ if modules-versioning)
1001
1002System modulefiles can safely be placed in:
1003PREFIX/Modules/modulefiles
1004]])
1005dnl ---------------------------------------------------------------------------
1006dnl Now put it all out!
1007dnl ---------------------------------------------------------------------------
1008AC_CONFIG_FILES([Makefile modules.lsm .spec doc/Makefile
1009	init/Makefile init/.modulespath
1010	doc/module.1 doc/modulefile.4
1011	etc/Makefile etc/add.modules etc/mkroot
1012	etc/skel/.cshrc etc/skel/.login
1013	etc/skel/.kshenv etc/skel/.profile
1014	etc/global/csh.cshrc etc/global/csh.login etc/global/csh.modules
1015	etc/global/bashrc etc/global/profile etc/global/profile.modules
1016	ext/Makefile ext/add.ext ext/mkroot
1017	ext/common/.cshrc ext/common/.login
1018	ext/common/.kshenv ext/common/.profile
1019	modulefiles/Makefile modulefiles/modules
1020	modulefiles/module-git modulefiles/module-info modulefiles/null
1021	modulefiles/use.own modulefiles/dot modulefiles/version
1022	])
1023AC_CONFIG_FILES([gitlog2changelog.py], [chmod +x gitlog2changelog.py])
1024dnl We want these to be recreated for each install
1025dnl	init/bash init/csh init/ksh init/perl.pm init/python.py init/sh init/zsh
1026AC_CONFIG_COMMANDS([default],[[date > stamp-h]],[[]])
1027AC_OUTPUT
1028dnl
1029