1# configure.ac 2AC_INIT(top, 3.8beta1) 3 4# AX_CHECK_VARIADIC_MACROS... 5# ----- 6AC_DEFUN([AX_CHECK_VARIADIC_MACROS], 7[AC_MSG_CHECKING([for variadic macros]) 8AC_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)]) 12AC_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)]) 16_result="" 17if test "$ax_cv_c99_variadic" = "yes"; then 18 _result=" c99" 19 AC_DEFINE(HAVE_C99_VARIADIC_MACROS, 1, [Supports C99 style variadic macros]) 20fi 21if test "$ax_cv_gnu_variadic" = "yes"; then 22 _result="$_result gnu" 23 AC_DEFINE(HAVE_GNU_VARIADIC_MACROS, 1, [Supports gnu style variadic macros]) 24fi 25if test "x$_result" = x; then 26 _result="no" 27fi 28AC_MSG_RESULT($_result) 29]) 30 31# AC_CHECK_CFLAG... 32# ----- 33AC_DEFUN([AC_CHECK_CFLAG], 34[AC_MSG_CHECKING([whether compiler accepts $1]) 35AS_VAR_PUSHDEF([ac_Flag], [ac_cv_cflag_$1])dnl 36_savedcflags=$CFLAGS 37_savedwerror_flag=$ac_c_werror_flag 38ac_c_werror_flag=yes 39CFLAGS=$CFLAGS" $1" 40AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [AS_VAR_SET(ac_Flag, yes)], 41 [AS_VAR_SET(ac_Flag, no)]) 42AC_MSG_RESULT([AS_VAR_GET(ac_Flag)]) 43CFLAGS=$_savedcflags 44ac_c_werror_flag=$_savedwerror_flag 45AS_IF([test AS_VAR_GET(ac_Flag) = yes], [$2], [$3])[]dnl 46AS_VAR_POPDEF([ac_Flag])dnl 47])# AC_CHECK_CFLAG 48 49echo "Configuring $PACKAGE_STRING" 50 51AC_CONFIG_HEADER([config.h]) 52AC_CANONICAL_BUILD 53AC_CANONICAL_HOST 54AC_CANONICAL_TARGET 55 56# options processing 57AC_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]) 61 62AC_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" 67 OBJ="$OBJ $withval.o" 68 else 69 AC_MSG_ERROR([No such extension $withval]) 70 fi]) 71 72DEFAULT_TOPN=30 73AC_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 76 DEFAULT_TOPN="-1" 77 elif test x`echo $with_default_topn | tr -d '[0-9+-]'` = x; then 78 DEFAULT_TOPN=$with_default_topn 79 fi]) 80AC_DEFINE_UNQUOTED(DEFAULT_TOPN, $DEFAULT_TOPN, [Default number of processes to display]) 81AC_SUBST(DEFAULT_TOPN) 82 83NOMINAL_TOPN=40 84AC_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 87 NOMINAL_TOPN="-1" 88 elif test x`echo $with_nominal_topn | tr -d '[0-9+-]'` = x; then 89 NOMINAL_TOPN=$with_nominal_topn 90 fi]) 91AC_DEFINE_UNQUOTED(NOMINAL_TOPN, $NOMINAL_TOPN, [Default number of processes to display on non-terminals when topn is all]) 92AC_SUBST(NOMINAL_TOPN) 93 94DEFAULT_DELAY=5 95AC_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 99 fi]) 100AC_DEFINE_UNQUOTED(DEFAULT_DELAY, $DEFAULT_DELAY, [Default delay]) 101AC_SUBST(DEFAULT_DELAY) 102 103AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], 104 [enable support for debugging output])) 105if test "x$enable_debug" = xyes; then 106 AC_DEFINE(DEBUG, 1, [Support for debugging output]) 107fi 108 109ENABLE_KILL=0 110AC_ARG_ENABLE(kill, AC_HELP_STRING([--disable-kill], 111 [disable kill and renice commands])) 112if test x$enable_kill != xno; then 113 AC_DEFINE(ENABLE_KILL, 1, [Enable kill and renice]) 114 ENABLE_KILL=1 115fi 116AC_SUBST(ENABLE_KILL) 117 118 119AC_ARG_ENABLE(color, AC_HELP_STRING([--disable-color], 120 [disable the use of color])) 121AC_ARG_ENABLE(colour, AC_HELP_STRING([--disable-colour], 122 [synonym for --disable-color])) 123if test x$enable_color != xno -a x$enable_colour != xno; then 124 AC_DEFINE(ENABLE_COLOR, 1, [Enable color]) 125fi 126 127AC_ARG_ENABLE(dualarch, AC_HELP_STRING([--enable-dualarch], 128 [enable or disable a dual architecture (32-bit and 64-bit) compile])) 129 130# check for needed programs 131AC_CHECK_PROGS(MAKE, make) 132AC_PROG_CC 133if test "$ac_cv_c_compiler_gnu" = "yes"; then 134 ax_cv_c_compiler_vendor="gnu" 135else 136 AX_COMPILER_VENDOR 137fi 138AC_PROG_AWK 139AC_PROG_INSTALL 140AC_PATH_PROGS(ISAINFO, isainfo) 141AC_PATH_PROGS(ISAEXEC, isaexec, , [$PATH:/usr/lib:/lib]) 142AC_PATH_PROGS(UNAME, uname) 143AC_SUBST(ISAEXEC) 144 145# system checks require uname 146if 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` 150 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.]) 156 fi 157 else 158 AC_DEFINE(OSREV, "") 159 fi 160 AC_MSG_RESULT($osrev) 161 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]) 167 fi 168 AC_MSG_RESULT($UNAME_HARDWARE) 169fi 170 171# checks for libraries 172AC_CHECK_LIB(elf, elf32_getphdr) 173AC_CHECK_LIB(kstat, kstat_open) 174AC_CHECK_LIB(kvm, kvm_open) 175# -lmld -lmach 176AC_CHECK_LIB(mach, vm_statistics) 177AC_SEARCH_LIBS(tgetent, termcap curses ncurses) 178AC_CHECK_LIB(m, exp) 179 180# check for libraries required by extension 181extlibs="" 182if 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"` 185 do 186 saveLIBS=$LIBS 187 LIBS="$LIBS -l$lib" 188 AC_TRY_LINK(, [exit(0);], [extlibs="$extlibs -l$lib"], ) 189 LIBS=$saveLIBS 190 done 191 AC_MSG_RESULT($extlibs) 192 LIBS="$LIBS$extlibs" 193fi 194 195# checks for header files 196AC_HEADER_STDC 197AC_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]) 198AC_CHECK_HEADERS([term.h],,, 199[#if HAVE_CURSES_H 200#include <curses.h> 201#endif 202]) 203AC_HEADER_TIME 204AC_MSG_CHECKING(for a good signal.h) 205SIGNAL_H="no" 206for 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 208 SIGNAL_H=$f 209 break 210 fi 211done 212AC_MSG_RESULT($SIGNAL_H) 213if test "$SIGNAL_H" = "no"; then 214 SIGNAL_H="/dev/null" 215fi 216AC_SUBST(SIGNAL_H) 217 218# checks for typedefs, structures, and compiler characteristics. 219AX_CHECK_VARIADIC_MACROS 220AC_CHECK_DECLS([sys_errlist]) 221AC_CHECK_DECLS([sys_signame],,, 222[#include <signal.h> 223/* NetBSD declares sys_siglist in unistd.h. */ 224#if HAVE_UNISTD_H 225# include <unistd.h> 226#endif 227]) 228AC_CHECK_DECLS([tputs, tgoto, tgetent, tgetflag, tgetnum, tgetstr],,, 229[#if HAVE_CURSES_H && HAVE_TERM_H 230#include <curses.h> 231#include <term.h> 232#else 233#if HAVE_TERMCAP_H 234#include <termcap.h> 235#else 236#if HAVE_CURSES_H 237#include <curses.h> 238#endif 239#endif 240#endif 241]) 242 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. 246AC_MSG_CHECKING([argument type of tputs putc function]) 247_savedwerror_flag=$ac_c_werror_flag 248ac_c_werror_flag=yes 249AC_COMPILE_IFELSE( 250[AC_LANG_PROGRAM([#ifdef HAVE_TERMCAP_H 251#include <termcap.h> 252#endif 253#ifdef HAVE_CURSES_H 254#include <curses.h> 255#endif 256#ifdef HAVE_TERM_H 257#include <term.h> 258#endif 259int f(char i) { }], 260[tputs("a", 1, f);])], 261 [ac_cv_type_tputs_putc="char"], 262 [ac_cv_type_tputs_putc="int"]) 263AC_MSG_RESULT($ac_cv_type_tputs_putc) 264AC_DEFINE_UNQUOTED(TPUTS_PUTC_ARGTYPE, $ac_cv_type_tputs_putc, 265 [Define as the type for the argument to the 266putc function of tputs ('int' or 'char')]) 267ac_c_werror_flag=$_savedwerror_flag 268 269# Determine presence of needed types 270AC_TYPE_SIGNAL 271AC_CHECK_TYPES([id_t, lwpid_t, pid_t, time_t, uid_t]) 272 273# Checks for library functions. 274AC_CHECK_FUNCS([getopt getopt_long gettimeofday memcpy setbuffer setpriority setvbuf strcasecmp strchr strerror snprintf sighold sigrelse sigaction sigprocmask sysconf uname vsnprintf]) 275 276# this is needed in the man page 277if test "x$ac_cv_func_getopt_long" = "xyes"; then 278 HAVE_GETOPT_LONG=1 279else 280 HAVE_GETOPT_LONG=0 281fi 282AC_SUBST(HAVE_GETOPT_LONG) 283 284# if we dont have snprintf/vsnprint then we need to compile the alternate 285if 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" 288fi 289 290 291# determine correct user, group, and mode 292# these can be overridden later if need be 293AC_MSG_CHECKING(for correct ls options) 294lslong="ls -l" 295if test `$lslong -d . | wc -w` -lt 9; then 296 lslong="ls -lg" 297fi 298AC_MSG_RESULT($lslong) 299 300 301# determine correct module 302AC_MSG_CHECKING(for a platform module) 303if test "$with_module"; then 304 MODULE=$with_module 305else 306 case $target_os in 307 aix4.2*) MODULE=aix43;; 308 aix4.3*) MODULE=aix43;; 309 aix5*) MODULE=aix5;; 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;; 328 darwin*) 329 echo "macosx" 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]);; 334 *) echo "none" 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:" 339echo "uname -a | mail -s $target_os bill@lefebvre.org" 340 echo "" 341 AC_MSG_ERROR([System type $target_os unrecognized]) 342 esac 343fi 344AC_MSG_RESULT($MODULE) 345SRC="$SRC machine/m_$MODULE.c" 346OBJ="$OBJ m_$MODULE.o" 347CLEAN_EXTRA="" 348AC_SUBST(SRC) 349AC_SUBST(OBJ) 350AC_SUBST(CLEAN_EXTRA) 351AC_DEFINE_UNQUOTED(MODULE, "$MODULE", [Platform module]) 352 353FIRST_RULE=/dev/null 354INSTALL_RULE=config.default.makeinstall 355 356# extra things that need to be done for certain systems 357# also handle setup for 64-bit detection 358bits="default" 359case $MODULE in 360 aix5) 361 AC_CHECK_LIB(perfstat, perfstat_cpu_total) 362 if test -f /usr/sbin/bootinfo; then 363 bits="`/usr/sbin/bootinfo -K`" 364 extra_flag="-q64" 365 fi 366 ;; 367 svr5) 368 # -lmas 369 AC_CHECK_LIB(mas, mas_open) 370 ;; 371 sunos5) 372 if test "$ISAINFO"; then 373 bits="`$ISAINFO -b`" 374 if test "$target_cpu" = "sparc"; then 375 extra_flag="-xarch=v9" 376 else 377 extra_flag="-xarch=amd64" 378 fi 379 fi 380 ;; 381esac 382 383# USE_FPH means the module has format_process_header 384if test -n "$USE_FPH"; then 385 AC_DEFINE(HAVE_FORMAT_PROCESS_HEADER, 1, [Platform module]) 386fi 387 388# if we are 64-bit, try to turn on the appropriate flags 389AC_MSG_CHECKING(address space size) 390ARCHFLAG="" 391if test "$bits" = "64"; then 392 AC_MSG_RESULT(64) 393 if test "$ax_cv_c_compiler_vendor" = "gnu"; then 394 extra_flag="-m64" 395 fi 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"]) 399else 400 AC_MSG_RESULT($bits) 401fi 402AC_SUBST(ARCHFLAG) 403 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. 407if 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" 413 else 414 enable_dualarch="no" 415 fi 416 fi 417 if test "x$enable_dualarch" = "xyes"; then 418 AC_MSG_RESULT(yes) 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 424 else 425 FIRST_RULE="config.amd64.make" 426 INSTALL_RULE="config.amd64.makeinstall" 427 CLEAN_EXTRA="$CLEAN_EXTRA i386/* amd64/*" 428 mkdir -p i386 amd64 429 fi 430 else 431 AC_MSG_RESULT(no) 432 fi 433fi 434 435if test x$enable_dualarch = xyes; then 436 AC_DEFINE(ENABLE_DUALARCH, 1, [Enable dual architecture]) 437fi 438 439AC_SUBST_FILE(FIRST_RULE) 440AC_SUBST_FILE(INSTALL_RULE) 441 442AC_MSG_CHECKING(for installation settings) 443# calculate appropriate settings 444OWNER="" 445GROUP="" 446MODE="" 447if test ! -n "$USE_KMEM" -a -d /proc; then 448# make sure we are installed so that we can read /proc 449 rm -f conftest.txt 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 454# linux-style /proc? 455 $lslong /proc/1/stat >conftest.txt 456 else 457 echo "-r--r--r-- 1 bin bin 32 Jan 1 12:00 /foo" >conftest.txt 458 fi 459 460# set permissions so that we can read stuff in /proc 461 if grep '^.......r..' conftest.txt >/dev/null; then 462# world readable 463 MODE=755 464 elif grep '^....r.....' conftest.txt >/dev/null; then 465# group readable 466 MODE=2711 467 GROUP=`awk ' { print $4 }'` 468 else 469# probably only readable by root 470 MODE=4711 471 OWNER=`awk ' { print $3 }'` 472 fi 473 474elif test -c /dev/kmem; then 475 $lslong -L /dev/kmem >conftest.txt 476 if grep '^....r..r..' conftest.txt >/dev/null; then 477 MODE=755 478 elif grep '^....r..-..' conftest.txt >/dev/null; then 479 MODE=2755 480 GROUP=`$AWK ' { print $4 }' conftest.txt` 481 fi 482else 483 MODE=755 484fi 485rm -f conftest.txt 486# let module settings override what we calculated 487OWNER=${SET_OWNER:-$OWNER} 488GROUP=${SET_GROUP:-$GROUP} 489MODE=${SET_MODE:-$MODE} 490 491# set only those things that require it 492result="" 493INSTALL_OPTS_PROG="" 494if test x$OWNER != x; then 495 result="${result}owner=$OWNER, " 496 INSTALL_OPTS_PROG="$INSTALL_OPTS_PROG -o $OWNER" 497fi 498if test x$GROUP != x; then 499 result="${result}group=$GROUP, " 500 INSTALL_OPTS_PROG="$INSTALL_OPTS_PROG -g $GROUP" 501fi 502result="${result}mode=$MODE" 503INSTALL_OPTS_PROG="$INSTALL_OPTS_PROG -m $MODE" 504 505AC_MSG_RESULT($result) 506 507# add extra cflags if the compiler accepts them 508AX_CFLAGS_WARN_ALL 509MODULE_CFLAGS="" 510if 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]) 514 fi 515fi 516 517# Define man page supplement 518MAN_SUPPLEMENT=machine/m_$MODULE.man 519AC_SUBST_FILE(MAN_SUPPLEMENT) 520 521# Extra things we want substituted 522AC_SUBST(MODULE) 523AC_SUBST(MODULE_CFLAGS) 524AC_SUBST(INSTALL_OPTS_PROG) 525 526# wrapup 527 528AC_CONFIG_FILES(Makefile top.1) 529AC_OUTPUT 530