⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 configure.ac

📁 测试内存泄露工具
💻 AC
📖 第 1 页 / 共 2 页
字号:
## Process this file with autoconf to produce a configure script.## Copyright 2003 by Gray Watson## This file is part of the dmalloc package.## Permission to use, copy, modify, and distribute this software for# any purpose and without fee is hereby granted, provided that the# above copyright notice and this permission notice appear in all# copies, and that the name of Gray Watson not be used in# advertising or publicity pertaining to distribution of the# document or software without specific, written prior permission.## Gray Watson makes no representations about the suitability of the# software described herein for any purpose.  It is provided "as is"# without express or implied warranty.## The author may be contacted via http://dmalloc.com/## $Id: configure.ac,v 1.29 2004/10/19 14:50:52 gray Exp $#AC_REVISION($Revision: 1.29 $)AC_INIT(dmalloc, 5.4.2, [http://dmalloc.com/])AC_CONFIG_SRCDIR(dmalloc.c)AC_CONFIG_HEADER(conf.h)AC_MSG_NOTICE([configurations for the dmalloc library])############################################################################### argumentsAC_ARG_ENABLE(cxx,    [ AC_HELP_STRING([--disable-cxx],		[do not build in C++ support (enabled by default)] ) ],    [ # enable_cxx set by default ],    [ enable_cxx=yes ])AC_ARG_ENABLE(threads,    [ AC_HELP_STRING([--enable-threads],		[build in thread support (disabled by default)] ) ],    [ # enable_threads set by default ],    [ enable_threads=no ])AC_ARG_ENABLE(shlib,    [ AC_HELP_STRING([--enable-shlib],		[build shared libraries (disabled by default)] ) ],    [ # enable_shlib set by default ],    [ enable_shlib=no ])##############################################################################AC_MSG_NOTICE([build utilities])AC_PROG_CCAC_PROG_CXX# hopefully we have a stdc c-compilerif test "$ac_cv_prog_cc_stdc" = "no" ; then	AC_MSG_WARN()	AC_MSG_WARN(WARNING: no ansi compiler.  this build may fail.)	AC_MSG_WARN()fiAC_PROG_INSTALLAC_PROG_RANLIBAC_C_CONST# we need this for various settingsAC_HEADER_STDCAC_CHECK_HEADER([stdarg.h],		[AC_DEFINE(HAVE_STDARG_H,1) AC_SUBST([HAVE_STDARG_H],1)],		[AC_DEFINE(HAVE_STDARG_H,0) AC_SUBST([HAVE_STDARG_H],0)])AC_CHECK_HEADER([stdlib.h],		[AC_DEFINE(HAVE_STDLIB_H,1) AC_SUBST([HAVE_STDLIB_H],1)],		[AC_DEFINE(HAVE_STDLIB_H,0) AC_SUBST([HAVE_STDLIB_H],0)])AC_CHECK_HEADER([string.h],		[AC_DEFINE(HAVE_STRING_H,1) AC_SUBST([HAVE_STRING_H],1)],		[AC_DEFINE(HAVE_STRING_H,0) AC_SUBST([HAVE_STRING_H],0)])AC_CHECK_HEADER([unistd.h],		[AC_DEFINE(HAVE_UNISTD_H,1) AC_SUBST([HAVE_UNISTD_H],1)],		[AC_DEFINE(HAVE_UNISTD_H,0) AC_SUBST([HAVE_UNISTD_H],0)])AC_CHECK_HEADER([sys/types.h],		[AC_DEFINE(HAVE_SYS_TYPES_H,1) AC_SUBST([HAVE_SYS_TYPES_H],1)],		[AC_DEFINE(HAVE_SYS_TYPES_H,0) AC_SUBST([HAVE_SYS_TYPES_H],0)])AC_CHECK_HEADER([sys/mman.h],		[AC_DEFINE(HAVE_SYS_MMAN_H,1) AC_SUBST([HAVE_SYS_MMAN_H],1)],		[AC_DEFINE(HAVE_SYS_MMAN_H,0) AC_SUBST([HAVE_SYS_MMAN_H],0)])################################################################################ shared library handling## check to see where we should install our shared libraries# DONT CACHE in case the change the --prefix## This is pretty tricky here and should be handled by autoconf# automatically.  I try to see if there is a shlib directory# to install by shlibs there.  If not I use the $libdir.  Some# of the variables have values of '${exec_prefix}' and the like# so the quoting is very important.## We first try and find the true directory where we are# installing.#if test "x$exec_prefix" = xNONE; then	if test "x$prefix" = xNONE; then		shlibprefix="$ac_default_prefix"	else		shlibprefix="$prefix"	fielse	shlibprefix="$exec_prefix"fi## Then we see if there is a special shlib directory to use.#if test -d $shlibprefix/shlib; then	shlibdir='${exec_prefix}/shlib'else	shlibdir="$libdir"fiAC_SUBST(shlibdir)# see how the local system builds shared librariesAC_MSG_CHECKING([shared library link args])AC_COMPILE_IFELSE([ int foo(int val) { return val + 1; } ],[	# so now we try to create an archive from the compiled .o file	(ar cr conftest.a conftest.o) 2>&5	# see which shared-library ld commands work	if (ld -shared --whole-archive -soname conftest.so -o conftest.so.t conftest.a) 2>&5; then		ac_cv_shared_link_args='ld -shared --whole-archive -soname $@ -o $@.t'	elif (ld -shared -o conftest.so.t -all -soname conftest.so.t -none -lc -all conftest.a) 2>&5; then		ac_cv_shared_link_args='ld -shared -o $@.t -all -soname $@ -none -lc -all'	elif (ld -G -o conftest.so.t conftest.a) 2>&5; then		ac_cv_shared_link_args='ld -G -o $@.t'	else		# oh well, toss an error		ac_cv_shared_link_args='# Could not configure shlib linking'		enable_shlib=no	fi],[	# oh well, toss an error	ac_cv_shared_link_args='# Could not configure shlib linking'	enable_shlib=no])shlinkargs="$ac_cv_shared_link_args"AC_MSG_RESULT([$ac_cv_shared_link_args])AC_SUBST(shlinkargs)###############################################################################AC_MSG_CHECKING([C++ support])if test "$enable_cxx" = "yes"; then	AC_SUBST([CXX_ON],[])	AC_SUBST([CXX_OFF],[#])	AC_MSG_RESULT([enabled])else	AC_SUBST([CXX_ON],[#])	AC_SUBST([CXX_OFF],[])	AC_MSG_RESULT([disabled])fiAC_MSG_CHECKING([thread support])if test "$enable_threads" = "yes"; then	AC_SUBST([TH_ON],[])	AC_SUBST([TH_OFF],[#])	AC_MSG_RESULT([enabled])else	AC_SUBST([TH_ON],[#])	AC_SUBST([TH_OFF],[])	AC_MSG_RESULT([disabled])fi# shlib supportAC_MSG_CHECKING(shlib support)if test "$enable_shlib" = "yes"; then	AC_SUBST([SL_ON],[])	AC_SUBST([SL_OFF],[#])	AC_MSG_RESULT(enabled)else	AC_SUBST([SL_ON],[#])	AC_SUBST([SL_OFF],[])	AC_MSG_RESULT(disabled)fi################################################################################# check for size_t#AC_TYPE_SIZE_Tif test "$ac_cv_type_size_t" = "yes"; then	AC_DEFINE(DMALLOC_SIZE,size_t)else	AC_DEFINE(DMALLOC_SIZE,unsigned long)fi## check for unsigned-ness#AC_MSG_CHECKING([dmalloc size unsigned])AC_RUN_IFELSE([AC_LANG_SOURCE([[#if HAVE_SYS_TYPES_H#  include <sys/types.h>#endif#if HAVE_STDLIB_H#  include <stdlib.h>#endifmain() { DMALLOC_SIZE x = -1; if (x >= 0) exit(0); else exit(1); }]])],[AC_DEFINE(DMALLOC_SIZE_UNSIGNED,1)  AC_MSG_RESULT([yes])],[AC_DEFINE(DMALLOC_SIZE_UNSIGNED,0)  AC_MSG_RESULT([no])],[AC_DEFINE(DMALLOC_SIZE_UNSIGNED,0)  AC_MSG_RESULT([no])])## check for strdup macro (linux)#AC_MSG_CHECKING([strdup macro])AC_RUN_IFELSE([AC_LANG_SOURCE([[#if HAVE_STDLIB_H#  include <string.h>#endif#ifdef strdupmain() { exit(0); }#elsemain() { exit(1); }#endif]])],[ac_cv_strdup_macro=yes],[ac_cv_strdup_macro=no],[ac_cv_strdup_macro=no])AC_MSG_RESULT([$ac_cv_strdup_macro])## check for existance of mprotect and associated defines#AC_CHECK_FUNCS(mprotect)AC_MSG_CHECKING([mprotect works])AC_LINK_IFELSE([AC_LANG_PROGRAM([[#if HAVE_SYS_TYPES_H#  include <sys/types.h>#endif#if HAVE_SYS_MMAN_H#  include <sys/mman.h>#endif]],[[  int prot = PROT_NONE | PROT_READ | PROT_WRITE;  (void)mprotect(0, 0, prot);]])],[ AC_DEFINE(PROTECT_ALLOWED,1) AC_MSG_RESULT([yes]) ],[ AC_DEFINE(PROTECT_ALLOWED,0) AC_MSG_RESULT([no]) ])##############################################################################AC_MSG_NOTICE([important functionality])AC_CHECK_FUNCS(mmap)AC_CHECK_FUNCS(sbrk)if test x$ac_cv_func_mmap != xyes && x$ac_cv_func_sbrk != xyes; then	AC_MSG_WARN()	AC_MSG_WARN(WARNING: no mmap nor sbrk function.  See INTERNAL_MEMORY_SPACE in settings.dist.)	AC_MSG_WARN()fiAC_MSG_CHECKING([mmap usage])AC_RUN_IFELSE([AC_LANG_SOURCE([[#if HAVE_SYS_TYPES_H#  include <sys/types.h>#endif#if HAVE_SYS_MMAN_H#  include <sys/mman.h>#endifmain() {  /* so we know here that we could open /dev/zero and map to that but I      did not want the library to open another file-descriptor */  void *ret = mmap(0L, 10, PROT_READ | PROT_WRITE | PROT_EXEC,	           MAP_PRIVATE | MAP_ANON, -1 /* no fd */, 0 /* no offset */);  if (ret == MAP_FAILED) { exit(1); }  else { exit(0); }}]])],[ AC_DEFINE(USE_MMAP, 1) ac_cv_use_mmap=yes],[ AC_DEFINE(USE_MMAP, 0) ac_cv_use_mmap=no],[ AC_DEFINE(USE_MMAP, 0) ac_cv_use_mmap=no])AC_MSG_RESULT([$ac_cv_use_mmap])## check for basic block size#AC_CHECK_FUNCS(getpagesize)AC_MSG_CHECKING([basic-block size])ac_cv_page_size=0if test $ac_cv_page_size = 0; then   AC_RUN_IFELSE([main() { if (getpagesize()<=2048) exit(0); else exit(1); }],	[ ac_cv_page_size=11 ] )fiif test $ac_cv_page_size = 0; then   AC_RUN_IFELSE([main() { if (getpagesize()<=4096) exit(0); else exit(1); }],	[ ac_cv_page_size=12 ] )fiif test $ac_cv_page_size = 0; then   AC_RUN_IFELSE([main() { if (getpagesize()<=8192) exit(0); else exit(1); }],	[ ac_cv_page_size=13 ] )fiif test $ac_cv_page_size = 0; then   AC_RUN_IFELSE([main() { if (getpagesize()<=16384) exit(0); else exit(1); }],	[ ac_cv_page_size=14 ] )fiif test $ac_cv_page_size = 0; then    ac_cv_page_size=15fiAC_DEFINE_UNQUOTED([BASIC_BLOCK],[$ac_cv_page_size])AC_MSG_RESULT([$ac_cv_page_size])## data-alignment size...#AC_CHECK_SIZEOF(long)AC_MSG_CHECKING([data-alignment size])if test $ac_cv_sizeof_long = 4; then	# we have to make a special case for sun sparc idiocy	ac_cv_data_align=8else	ac_cv_data_align=$ac_cv_sizeof_longfiAC_DEFINE_UNQUOTED([ALLOCATION_ALIGNMENT],[$ac_cv_data_align])AC_MSG_RESULT([$ac_cv_data_align])## check the safety of the abort function#AC_CHECK_FUNCS(abort)AC_MSG_CHECKING([abort safe])AC_RUN_IFELSE([[static int main_b = 0;static char heap_mem[102400], *heap_p = heap_mem;free () { if (main_b) _exit(0); }char *malloc (int size) {  char *pnt;  if (main_b) _exit(0);  pnt = heap_p;  heap_p += size;  return pnt;}char *calloc (int number, int size) {  char *start, *pnt, *end;  if (main_b) _exit(0);  /* it should be already 0s */  start = malloc (number * size);  pnt = start;  end = start + size;  while (pnt < end) { *pnt++ = '\0'; }  return start;}char *realloc (char *old_pnt, int new_size) {  char *start, *pnt, *end;  if (main_b) _exit(0);  start = malloc (new_size);  pnt = start;  end = start + new_size;  while (pnt < end) { *pnt++ = *old_pnt++; }  return start;}main() { main_b = 1; abort(); _exit(1); }]],# NOTE: this is reversed because abort core dumps and doesn't exit with# 0 which means that it should fail[ AC_DEFINE(ABORT_OKAY, 0) AC_MSG_RESULT([no]) ],# if it succeeds then something called free on the way out[ AC_DEFINE(ABORT_OKAY, 1) AC_MSG_RESULT([yes]) ],[ AC_DEFINE(ABORT_OKAY, 0) AC_MSG_RESULT([no]) ])AC_TYPE_SIGNALAC_MSG_CHECKING([signal works])AC_CHECK_HEADER([signal.h],		[AC_DEFINE(HAVE_SIGNAL_H,1) AC_SUBST([HAVE_SIGNAL_H],1)],		[AC_DEFINE(HAVE_SIGNAL_H,0) AC_SUBST([HAVE_SIGNAL_H],0)])AC_LINK_IFELSE([AC_LANG_PROGRAM([[#if HAVE_SIGNAL_H  #include <signal.h>#endif]], [[	(void)signal(SIGHUP, SIG_IGN);	(void)signal(SIGINT, SIG_IGN);	(void)signal(SIGTERM, SIG_IGN);]])],[ AC_DEFINE(SIGNAL_OKAY, 1) AC_MSG_RESULT([yes]) ],

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -