4 # AX_CHECK_VARIADIC_MACROS...
6 AC_DEFUN([AX_CHECK_VARIADIC_MACROS],
7 [AC_MSG_CHECKING([for variadic macros])
8 AC_COMPILE_IFELSE(AC_LANG_PROGRAM(
9 [#define a(x, ...) (x, __VA_ARGS__)], []),
10 [AS_VAR_SET(ax_cv_c99_variadic, yes)],
11 [AS_VAR_SET(ax_cv_c99_variadic, no)])
12 AC_COMPILE_IFELSE(AC_LANG_PROGRAM(
13 [#define a(x...) (x)], []),
14 [AS_VAR_SET(ax_cv_gnu_variadic, yes)],
15 [AS_VAR_SET(ax_cv_gnu_variadic, no)])
17 if test "$ax_cv_c99_variadic" = "yes"; then
19 AC_DEFINE(HAVE_C99_VARIADIC_MACROS, 1, [Supports C99 style variadic macros])
21 if test "$ax_cv_gnu_variadic" = "yes"; then
22 _result="$_result gnu"
23 AC_DEFINE(HAVE_GNU_VARIADIC_MACROS, 1, [Supports gnu style variadic macros])
25 if test "x$_result" = x; then
28 AC_MSG_RESULT($_result)
33 AC_DEFUN([AC_CHECK_CFLAG],
34 [AC_MSG_CHECKING([whether compiler accepts $1])
35 AS_VAR_PUSHDEF([ac_Flag], [ac_cv_cflag_$1])dnl
37 _savedwerror_flag=$ac_c_werror_flag
40 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [AS_VAR_SET(ac_Flag, yes)],
41 [AS_VAR_SET(ac_Flag, no)])
42 AC_MSG_RESULT([AS_VAR_GET(ac_Flag)])
44 ac_c_werror_flag=$_savedwerror_flag
45 AS_IF([test AS_VAR_GET(ac_Flag) = yes], [$2], [$3])[]dnl
46 AS_VAR_POPDEF([ac_Flag])dnl
49 echo "Configuring $PACKAGE_STRING"
51 AC_CONFIG_HEADER([config.h])
57 AC_ARG_WITH(module, AC_HELP_STRING([--with-module=NAME],
58 [use the platform module NAME]),
59 [if test ! -f machine/m_$withval.c;
60 then AC_MSG_ERROR([No such module $withval]); fi])
62 AC_ARG_WITH(ext, AC_HELP_STRING([--with-ext=EXT],
63 [use the extension EXT]),
64 [if test -f ext/$withval.c; then
65 AC_DEFINE(WITH_EXT, 1, [Include code that utilizes extensions])
66 SRC="$SRC ext/$withval.c"
69 AC_MSG_ERROR([No such extension $withval])
73 AC_ARG_WITH(default-topn, AC_HELP_STRING([--with-default-topn=N],
74 [use N as the default for number of processes]),
75 [if test x"$with_default_topn" = xall; then
77 elif test x`echo $with_default_topn | tr -d '[0-9+-]'` = x; then
78 DEFAULT_TOPN=$with_default_topn
80 AC_DEFINE_UNQUOTED(DEFAULT_TOPN, $DEFAULT_TOPN, [Default number of processes to display])
81 AC_SUBST(DEFAULT_TOPN)
84 AC_ARG_WITH(nominal-topn, AC_HELP_STRING([--with-nominal-topn=N],
85 [use N as the default number of processes for non-terminals]),
86 [if test x"$with_nominal_topn" = xall; then
88 elif test x`echo $with_nominal_topn | tr -d '[0-9+-]'` = x; then
89 NOMINAL_TOPN=$with_nominal_topn
91 AC_DEFINE_UNQUOTED(NOMINAL_TOPN, $NOMINAL_TOPN, [Default number of processes to display on non-terminals when topn is all])
92 AC_SUBST(NOMINAL_TOPN)
95 AC_ARG_WITH(default-delay, AC_HELP_STRING([--with-default-delay=SEC],
96 [use a default delay of SEC seconds]),
97 [if test x`echo $with_default_delay | tr -d '[0-9+-]'` = x; then
98 DEFAULT_DELAY=$with_default_delay
100 AC_DEFINE_UNQUOTED(DEFAULT_DELAY, $DEFAULT_DELAY, [Default delay])
101 AC_SUBST(DEFAULT_DELAY)
103 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug],
104 [enable support for debugging output]))
105 if test "x$enable_debug" = xyes; then
106 AC_DEFINE(DEBUG, 1, [Support for debugging output])
110 AC_ARG_ENABLE(kill, AC_HELP_STRING([--disable-kill],
111 [disable kill and renice commands]))
112 if test x$enable_kill != xno; then
113 AC_DEFINE(ENABLE_KILL, 1, [Enable kill and renice])
116 AC_SUBST(ENABLE_KILL)
119 AC_ARG_ENABLE(color, AC_HELP_STRING([--disable-color],
120 [disable the use of color]))
121 AC_ARG_ENABLE(colour, AC_HELP_STRING([--disable-colour],
122 [synonym for --disable-color]))
123 if test x$enable_color != xno -a x$enable_colour != xno; then
124 AC_DEFINE(ENABLE_COLOR, 1, [Enable color])
127 AC_ARG_ENABLE(dualarch, AC_HELP_STRING([--enable-dualarch],
128 [enable or disable a dual architecture (32-bit and 64-bit) compile]))
130 # check for needed programs
131 AC_CHECK_PROGS(MAKE, make)
133 if test "$ac_cv_c_compiler_gnu" = "yes"; then
134 ax_cv_c_compiler_vendor="gnu"
140 AC_PATH_PROGS(ISAINFO, isainfo)
141 AC_PATH_PROGS(ISAEXEC, isaexec, , [$PATH:/usr/lib:/lib])
142 AC_PATH_PROGS(UNAME, uname)
145 # system checks require uname
146 if test "$UNAME"; then
147 # we make the version number available as a C preprocessor definition
148 AC_MSG_CHECKING(OS revision number)
149 osrev=`$UNAME -r | tr -cd ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`
151 if test "$osrev" != "unknown" ; then
152 AC_DEFINE_UNQUOTED(OSREV, $osrev, [Define the OS revision.])
153 osmajor=`$UNAME -r | sed 's/^\([[0-9]]*\).*$/\1/'`
154 if test -n "$osmajor"; then
155 AC_DEFINE_UNQUOTED(OSMAJOR, $osmajor, [Define the major OS revision number.])
160 AC_MSG_RESULT($osrev)
162 # we make the non-canonicalized hardware type available
163 AC_MSG_CHECKING(hardware platform)
164 UNAME_HARDWARE=`$UNAME -m`
165 if test "$UNAME_HARDWARE" != "unknown"; then
166 AC_DEFINE_UNQUOTED(UNAME_HARDWARE, "$UNAME_HARDWARE", [Define the system hardware platform])
168 AC_MSG_RESULT($UNAME_HARDWARE)
171 # checks for libraries
172 AC_CHECK_LIB(elf, elf32_getphdr)
173 AC_CHECK_LIB(kstat, kstat_open)
174 AC_CHECK_LIB(kvm, kvm_open)
176 AC_CHECK_LIB(mach, vm_statistics)
177 AC_SEARCH_LIBS(tgetent, termcap curses ncurses)
180 # check for libraries required by extension
182 if test -n "$with_ext" -a -f "${srcdir}/ext/$with_ext.libs"; then
183 AC_MSG_CHECKING(for libraries needed by extensions)
184 for lib in `cat "${srcdir}/ext/$with_ext.libs"`
188 AC_TRY_LINK(, [exit(0);], [extlibs="$extlibs -l$lib"], )
191 AC_MSG_RESULT($extlibs)
195 # checks for header files
197 AC_CHECK_HEADERS([curses.h getopt.h limits.h math.h stdarg.h sysexits.h termcap.h unistd.h sys/resource.h sys/time.h sys/utsname.h])
198 AC_CHECK_HEADERS([term.h],,,
204 AC_MSG_CHECKING(for a good signal.h)
206 for f in /usr/include/signal.h /usr/include/sys/signal.h /usr/include/sys/iso/signal_iso.h /usr/include/bits/signum.h; do
207 if grep SIGKILL $f >/dev/null 2>&1; then
212 AC_MSG_RESULT($SIGNAL_H)
213 if test "$SIGNAL_H" = "no"; then
218 # checks for typedefs, structures, and compiler characteristics.
219 AX_CHECK_VARIADIC_MACROS
220 AC_CHECK_DECLS([sys_errlist])
221 AC_CHECK_DECLS([sys_signame],,,
223 /* NetBSD declares sys_siglist in unistd.h. */
228 AC_CHECK_DECLS([tputs, tgoto, tgetent, tgetflag, tgetnum, tgetstr],,,
229 [#if HAVE_CURSES_H && HAVE_TERM_H
243 # The third argument to tputs is a putc-like function that takes an
244 # argument. On most systems that argument is an int, but on some it
245 # is a char. Determine which.
246 AC_MSG_CHECKING([argument type of tputs putc function])
247 _savedwerror_flag=$ac_c_werror_flag
250 [AC_LANG_PROGRAM([#ifdef HAVE_TERMCAP_H
260 [tputs("a", 1, f);])],
261 [ac_cv_type_tputs_putc="char"],
262 [ac_cv_type_tputs_putc="int"])
263 AC_MSG_RESULT($ac_cv_type_tputs_putc)
264 AC_DEFINE_UNQUOTED(TPUTS_PUTC_ARGTYPE, $ac_cv_type_tputs_putc,
265 [Define as the type for the argument to the
266 putc function of tputs ('int' or 'char')])
267 ac_c_werror_flag=$_savedwerror_flag
269 # Determine presence of needed types
271 AC_CHECK_TYPES([id_t, lwpid_t, pid_t, time_t, uid_t])
273 # Checks for library functions.
274 AC_CHECK_FUNCS([getopt getopt_long gettimeofday memcpy setbuffer setpriority setvbuf strcasecmp strchr strerror snprintf sighold sigrelse sigaction sigprocmask sysconf uname vsnprintf])
276 # this is needed in the man page
277 if test "x$ac_cv_func_getopt_long" = "xyes"; then
282 AC_SUBST(HAVE_GETOPT_LONG)
284 # if we dont have snprintf/vsnprint then we need to compile the alternate
285 if test "x$ac_cv_func_snprintf" != "xyes" -o "x$ac_cv_func_vsnprintf" != "xyes"; then
286 SRC="$SRC ap_snprintf.c"
287 OBJ="$OBJ ap_snprintf.o"
291 # determine correct user, group, and mode
292 # these can be overridden later if need be
293 AC_MSG_CHECKING(for correct ls options)
295 if test `$lslong -d . | wc -w` -lt 9; then
298 AC_MSG_RESULT($lslong)
301 # determine correct module
302 AC_MSG_CHECKING(for a platform module)
303 if test "$with_module"; then
307 aix4.2*) MODULE=aix43;;
308 aix4.3*) MODULE=aix43;;
310 dec-osf*) MODULE=decosf1;;
311 osf1*) MODULE=decosf1;;
312 osf4*) MODULE=decosf1;;
313 osf5*) MODULE=decosf1;;
314 freebsd*) MODULE=freebsd; USE_KMEM=1; USE_FPH=1;;
315 hpux7*) MODULE=hpux7;;
316 hpux8*) MODULE=hpux8;;
317 hpux9*) MODULE=hpux9;;
318 hpux10*) MODULE=hpux10;;
319 hpux11*) MODULE=hpux10;;
320 irix5*) MODULE=irix5;;
321 irix6*) MODULE=irixsgi;;
322 linux*) MODULE=linux; USE_FPH=1; SET_MODE=755;;
323 netbsd*) MODULE=netbsd; SET_MODE=755;;
324 solaris2*) MODULE=sunos5; USE_FPH=1; SET_MODE=755;;
325 sunos4*) MODULE=sunos4;;
326 sysv4*) MODULE=svr4;;
327 sysv5*) MODULE=svr5;;
330 echo "The macosx module is untested. Use at your own risk."
331 echo "If you really want to use this module, please run configure as follows:"
332 echo " ./configure --with-module=macosx"
333 AC_MSG_ERROR([macosx module unsupported]);;
335 echo "Configure doesn't recognize this system and doesn't know"
336 echo "what module to assign to it. Help the cause and run the"
337 echo "following command to let the maintainers know about this"
338 echo "deficiency! Thanks. Just cut and paste the following:"
339 echo "uname -a | mail -s $target_os bill@lefebvre.org"
341 AC_MSG_ERROR([System type $target_os unrecognized])
344 AC_MSG_RESULT($MODULE)
345 SRC="$SRC machine/m_$MODULE.c"
346 OBJ="$OBJ m_$MODULE.o"
350 AC_SUBST(CLEAN_EXTRA)
351 AC_DEFINE_UNQUOTED(MODULE, "$MODULE", [Platform module])
354 INSTALL_RULE=config.default.makeinstall
356 # extra things that need to be done for certain systems
357 # also handle setup for 64-bit detection
361 AC_CHECK_LIB(perfstat, perfstat_cpu_total)
362 if test -f /usr/sbin/bootinfo; then
363 bits="`/usr/sbin/bootinfo -K`"
369 AC_CHECK_LIB(mas, mas_open)
372 if test "$ISAINFO"; then
374 if test "$target_cpu" = "sparc"; then
375 extra_flag="-xarch=v9"
377 extra_flag="-xarch=amd64"
383 # USE_FPH means the module has format_process_header
384 if test -n "$USE_FPH"; then
385 AC_DEFINE(HAVE_FORMAT_PROCESS_HEADER, 1, [Platform module])
388 # if we are 64-bit, try to turn on the appropriate flags
389 AC_MSG_CHECKING(address space size)
391 if test "$bits" = "64"; then
393 if test "$ax_cv_c_compiler_vendor" = "gnu"; then
396 # Make sure our compiler accepts the flag we want to use
397 AC_CHECK_CFLAG($extra_flag, [ARCHFLAG="$extra_flag"],
398 [enable_dualarch="no"])
404 # Dual architecture handling: for now this is only enabled on Solaris.
405 # Config options can explicitly enable or disable dualarch. Otherwise,
406 # dualarch is only enabled when we are on a 64-bit system.
407 if test "$MODULE" = "sunos5"; then
408 AC_MSG_CHECKING(for dual architecture compilation)
409 if test "x$enable_dualarch" = x; then
410 # we must make the determination implicitly
411 if test "$bits" = "64"; then
412 enable_dualarch="yes"
417 if test "x$enable_dualarch" = "xyes"; then
419 if test "$target_cpu" = "sparc"; then
420 FIRST_RULE="config.sparcv9.make"
421 INSTALL_RULE="config.sparcv9.makeinstall"
422 CLEAN_EXTRA="$CLEAN_EXTRA sparcv7/* sparcv9/*"
423 mkdir -p sparcv7 sparcv9
425 FIRST_RULE="config.amd64.make"
426 INSTALL_RULE="config.amd64.makeinstall"
427 CLEAN_EXTRA="$CLEAN_EXTRA i386/* amd64/*"
435 if test x$enable_dualarch = xyes; then
436 AC_DEFINE(ENABLE_DUALARCH, 1, [Enable dual architecture])
439 AC_SUBST_FILE(FIRST_RULE)
440 AC_SUBST_FILE(INSTALL_RULE)
442 AC_MSG_CHECKING(for installation settings)
443 # calculate appropriate settings
447 if test ! -n "$USE_KMEM" -a -d /proc; then
448 # make sure we are installed so that we can read /proc
450 if test -r /proc/0/psinfo; then
451 # system uses solaris-style /proc
452 $lslong /proc/0/psinfo >conftest.txt
453 elif test -r /proc/1/stat; then
455 $lslong /proc/1/stat >conftest.txt
457 echo "-r--r--r-- 1 bin bin 32 Jan 1 12:00 /foo" >conftest.txt
460 # set permissions so that we can read stuff in /proc
461 if grep '^.......r..' conftest.txt >/dev/null; then
464 elif grep '^....r.....' conftest.txt >/dev/null; then
467 GROUP=`awk ' { print $4 }'`
469 # probably only readable by root
471 OWNER=`awk ' { print $3 }'`
474 elif test -c /dev/kmem; then
475 $lslong -L /dev/kmem >conftest.txt
476 if grep '^....r..r..' conftest.txt >/dev/null; then
478 elif grep '^....r..-..' conftest.txt >/dev/null; then
480 GROUP=`$AWK ' { print $4 }' conftest.txt`
486 # let module settings override what we calculated
487 OWNER=${SET_OWNER:-$OWNER}
488 GROUP=${SET_GROUP:-$GROUP}
489 MODE=${SET_MODE:-$MODE}
491 # set only those things that require it
494 if test x$OWNER != x; then
495 result="${result}owner=$OWNER, "
496 INSTALL_OPTS_PROG="$INSTALL_OPTS_PROG -o $OWNER"
498 if test x$GROUP != x; then
499 result="${result}group=$GROUP, "
500 INSTALL_OPTS_PROG="$INSTALL_OPTS_PROG -g $GROUP"
502 result="${result}mode=$MODE"
503 INSTALL_OPTS_PROG="$INSTALL_OPTS_PROG -m $MODE"
505 AC_MSG_RESULT($result)
507 # add extra cflags if the compiler accepts them
510 if test "$ax_cv_c_compiler_vendor" = "gnu"; then
511 AX_CFLAGS_GCC_OPTION([-fno-strict-aliasing], [MODULE_CFLAGS])
512 if test "$target_cpu" = "alpha"; then
513 AX_CFLAGS_GCC_OPTION([-mfp-trap-mode=sui -mtrap-precision=i])
517 # Define man page supplement
518 MAN_SUPPLEMENT=machine/m_$MODULE.man
519 AC_SUBST_FILE(MAN_SUPPLEMENT)
521 # Extra things we want substituted
523 AC_SUBST(MODULE_CFLAGS)
524 AC_SUBST(INSTALL_OPTS_PROG)
528 AC_CONFIG_FILES(Makefile top.1)