Re: [HACKERS] Off-topic: autoconf guru

From: Patrick van Kleef <pvk(at)pobox(dot)com>
To: Dmitry Samersoff <dms(at)wplus(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [HACKERS] Off-topic: autoconf guru
Date: 1999-07-29 14:59:43
Message-ID: 199907291459.QAA10044@roadrunner.pvk.openlinksw.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Dmitry,

Autoconf can do this out of the box. With the macros AC_LANG_C and
AC_LANG_CPLUSPLUS you can switch between C and C++ compiler mode. Here
is a small example based on the snippet you provided:

AC_PREREQ(2.12)
AC_INIT(configure.in)

#
# Check which C and C++ compiler to use
#
AC_PROG_CC
AC_PROG_CXX

#
# The following checks are done with the C compiler
#
AC_LANG_C

AC_CHECK_FUNC(accept)

#
# Now switch over to the C++ compiler for the next test
#
AC_LANG_CPLUSPLUS

AC_MSG_CHECKING(socket size type)
AC_TRY_COMPILE([#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
],
[int a = accept(1, (struct sockaddr *) 0, (int *) 0);],
[AC_DEFINE(SOCKET_SIZE_TYPE, int) AC_MSG_RESULT(int)],
[AC_DEFINE(SOCKET_SIZE_TYPE, size_t) AC_MSG_RESULT(size_t)])

#
# Switch back to C mode again
#
AC_LANG_C

AC_OUTPUT()

Best regards,

Patrick
--
Patrick van Kleef
pkleef(at)roady(dot)xs4all(dot)nl

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ryan Kirkpatrick 1999-07-29 15:14:12 Re: [PORTS] RedHat6.0 & Alpha
Previous Message Tom Lane 1999-07-29 14:44:59 Re: [HACKERS] Max Query length string