Codebase list mbuffer / debian/20190113+ds1-1 configure.in
debian/20190113+ds1-1

Tree @debian/20190113+ds1-1 (Download .tar.gz)

configure.in @debian/20190113+ds1-1raw · history · blame

#
#  Copyright (C) 2000-2019, Thomas Maier-Komor
#
#  This is the source code of mbuffer.
#
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

AC_INIT([mbuffer],[20190113])
AC_CONFIG_HEADER([config.h])
AC_CONFIG_SRCDIR([mbuffer.c])
AC_LANG([C])

AC_CANONICAL_SYSTEM
AC_EXEEXT

if test "${LD_LIBRARY_PATH}" != "" ; then
	echo ""
	echo "    WARNING: LD_LIBRARY_PATH is set. This can cause severe problems!!!"
	echo "    Please learn about using RUNPATH instead of LD_LIBRARY_PATH - e.g. here:"
	echo "    - http://prefetch.net/articles/linkers.badldlibrary.html"
	echo "    For gcc, you can pass LDFLAGS=\"-R/usr/local/lib\" to configure,"
	echo "    instead of setting LD_LIBRARY_PATH."
	echo ""
	sleep 5
fi

AC_PREFIX_DEFAULT(/usr/local)
test "$prefix" = NONE && prefix=/usr/local
test "$exec_prefix" = NONE && exec_prefix=$prefix

USRCFLAGS=${CFLAGS}

AC_LANG_C
AC_PROG_CC_C99
AC_PROG_CC(cc gcc)
AC_C_RESTRICT
AC_C_INLINE

if test "${USRCFLAGS}" = "" ; then
	if test "${GCC}" = "yes" ; then
		CFLAGS="${CFLAGS} -O2 -Wall"
		cflags_tmp="${CFLAGS}"
		CFLAGS="${CFLAGS} -m64"
		AC_MSG_CHECKING([whether $CC supports $CFLAGS])
		AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
			[AC_MSG_RESULT([yes])],
			[AC_MSG_RESULT([no])]
			CFLAGS="$cflags_tmp"
		)
	else
		SUNCCVERSION=`${CC} -V 2>&1 | grep Sun`
		SUNCC=$?
		if test "${SUNCC}" == "0" ; then
			CFLAGS="${CFLAGS} -O"
			cflags_tmp="$CFLAGS"
			HAS_M64=`${CC} -flags | grep m64`
			if test "${HAS_M64}" != "" ; then
				CFLAGS="${CFLAGS} -m64"
				AC_MSG_CHECKING([whether $CC supports $CFLAGS])
				AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
					[AC_MSG_RESULT([yes])],
					[AC_MSG_RESULT([no])]
					CFLAGS="$cflags_tmp"
				)
			else
				CFLAGS="${CFLAGS} -xarch=generic64"
				AC_MSG_CHECKING([whether $CC supports $CFLAGS])
				AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
					[AC_MSG_RESULT([yes])],
					[AC_MSG_RESULT([no])]
					CFLAGS="$cflags_tmp"
				)
			fi
		else
			echo unknown cc
			CFLAGS="${CFLAGS} -O"
		fi
	fi
fi


cflags_tmp="$CFLAGS"
CFLAGS="$CFLAGS -Wno-unused-result"
AC_MSG_CHECKING([whether $CC provides -Wunused-result])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
	[AC_MSG_RESULT([yes])],
	[AC_MSG_RESULT([no])]
	CFLAGS="$cflags_tmp"
)

AC_SUBST(CFLAGS)

AC_PROG_INSTALL
AC_PATH_PROG(RM,rm)
AC_PATH_PROG(CP,cp)
AC_PATH_PROG(MT,mt,AC_MSG_WARN(could not find the program mt - you might need this if you want autoloader support))
AC_PATH_PROGS(TAR,[gtar tar])
AC_PATH_PROG(AWK,awk)
AC_PATH_PROGS(OBJDUMP,objdump gobjdump)
AC_TYPE_SIGNAL
AC_SYS_LARGEFILE
AC_STRUCT_ST_BLKSIZE

if test -z "$OBJDUMP"; then
	AC_MSG_ERROR([unable to find objdump])
fi

AC_HEADER_ASSERT
AC_CHECK_LIB(pthread, pthread_mutex_init)
AC_SEARCH_LIBS(dlsym,dl)
AC_SEARCH_LIBS(clock_gettime,rt,,AC_MSG_ERROR(could not find the library containing clock_gettime!))
AC_SEARCH_LIBS(sem_init,rt posix,,AC_MSG_ERROR(could not find semaphore functions!))
AC_SEARCH_LIBS(rint,m,,AC_MSG_ERROR(unable to find rint))
AC_SEARCH_LIBS(seteuid,c,AC_DEFINE([HAVE_SETEUID], [1], [Define to 1 if you have the seteuid() function]),)
AC_SEARCH_LIBS(atoll,c,,AC_DEFINE([atoll],[atol],[Define to 1 if you do not have the atoll() function to use atol() instead]))
AC_SEARCH_LIBS(hstrerror,resolv socket nsl,AC_DEFINE([HAVE_HSTRERROR], [1], [Define to 1 if you have the hstrerror() function]),)
AC_SEARCH_LIBS(getaddrinfo,resolv socket nsl ,AC_DEFINE([HAVE_GETADDRINFO], [1], [Define to 1 if you have the getaddrinfo() function]) ,AC_MSG_WARN(support for systems without getaddrinfo is deprecated and will be removed in the future))
AC_SEARCH_LIBS(socket,socket,,AC_MSG_ERROR(could not find the library containing network functions!))
AC_SEARCH_LIBS(gethostbyname,nsl,,AC_MSG_ERROR(could not find the library containing name convertion functions!))
AC_SEARCH_LIBS(sendfile,sendfile,AC_DEFINE([HAVE_SENDFILE],[1],[libsendfile is available]),)
AC_CHECK_HEADER(sys/sendfile.h,AC_DEFINE([HAVE_SENDFILE_H],[1],[sendfile in sendfile.h]),)
AC_FUNC_ALLOCA


AC_ARG_ENABLE(debug,
        [  --disable-debug         disable verbose logging to console for debugging purpose],
        ,enable_debug=yes
        )
if test x$enable_debug = xyes ; then
	AC_DEFINE([DEBUG], [1], [Define to 1 to build in debugging mode])
fi

AC_ARG_ENABLE(md5,
        [  --disable-md5           disable md5 hash generation],
	,enable_md5=auto
	)
if test x$enable_md5 != xno ; then
	AC_SEARCH_LIBS(MD5Init,md5 md,AC_DEFINE([HAVE_LIBMD5], [1], [Define to 1 if you have the md5 library]),)
	AC_CHECK_HEADER(md5.h,AC_DEFINE([HAVE_MD5_H],[1],[found md5.h]),)
	AC_SEARCH_LIBS(MD5_Init,crypto,AC_DEFINE([HAVE_LIBCRYPTO], [1], [Define to 1 if you have the OpenSSL crypto library]),)
fi


AC_MSG_CHECKING([linking open() and write() to detect libc names])
AC_LANG(C)
AC_LINK_IFELSE([
	AC_LANG_SOURCE([[
		#define _LARGEFILE64_SOURCE
		#include <unistd.h>
		#include <fcntl.h>
		#include <sys/stat.h>
		int main(int argc, char **argv) {
			unsigned x;
			struct stat st;
			open(*argv,O_RDONLY);
			fstat(0,&st);
			read(0,&x,sizeof(x));
			write(1,"null",4);
		}
	]])],[
	AC_MSG_RESULT([OK])
	AC_MSG_CHECKING([name of open() in C library])
	libc_open=`$OBJDUMP -T conftest | $AWK '/\*UND\*/ && $NF ~ /^open/ { print $NF }'`
	AC_DEFINE_UNQUOTED([LIBC_OPEN], $libc_open, [name of open() in libc])
	AC_MSG_RESULT($libc_open)
	AC_MSG_CHECKING([name of read() in C library])
	libc_read=`$OBJDUMP -T conftest | $AWK '/\*UND\*/ && $NF ~ /^read/ { print $NF }'`
	AC_DEFINE_UNQUOTED([LIBC_READ], $libc_read, [name of write() in libc])
	AC_MSG_RESULT($libc_read)
	AC_MSG_CHECKING([name of write() in C library])
	libc_write=`$OBJDUMP -T conftest | $AWK '/\*UND\*/ && $NF ~ /^write/ { print $NF }'`
	AC_DEFINE_UNQUOTED([LIBC_WRITE], $libc_write, [name of write() in libc])
	AC_MSG_RESULT($libc_write)
	AC_MSG_CHECKING([name of fstat() in C library])
	libc_fstat=`$OBJDUMP -T conftest | $AWK '/\*UND\*/ && $NF ~ /^fstat/ { print $NF }'`
	AC_DEFINE_UNQUOTED([LIBC_FSTAT], $libc_fstat, [name of fstat() in libc])
	AC_MSG_RESULT($libc_fstat)
	],
	[AC_MSG_FAILURE([failed to link open/write test])]
)


AC_SUBST(DEBUG)
AC_SUBST(prefix)
AC_SUBST(AUTOCONF)
AC_DEFINE(_REENTRANT,1,Needed for thread safe compilation)

AC_OUTPUT(Makefile mbuffer.1)

# vim:tw=0