Greetings. I am trying to create an autoconf configure script that automatically checks for which pthread option to use and, ideally, specifies -pthread when compiling with gcc.
It was my hope that AX_PTHREAD would work, but neither seems to work on MacOS 10.6.
I'm using AX_PTHREAD from http://www.nongnu.org/autoconf-archive/ax_pthread.html
For reasons that I do not understand, it just doesn't use the -pthread option for scripts build on a mac.
The problem seems to be that "none" is compiling without error, and as a result the other threads in the ax_pthread_flags variable aren't being checked.
So I've moved the -pthread case before the "none" case and added this case to the case statement:
-pthread)
PTHREAD_CFLAGS="-pthread"
PTHREAD_LIBS="-pthread"
;;
This seems to work, but I am not sure if it will work with non-GCC compilers. And I'm not even sure if I should care.
Equally annoying is the fact that the AX_PTHREAD macro only updates CFLAGS, not CPPFLAGS.
Is there a better way to test for the -pthread option using autoconf?
Autoconf is an extensible package of M4 macros that produce shell scripts to automatically configure software source code packages. These scripts can adapt the packages to many kinds of UNIX-like systems without manual user intervention.
To create a configure script with Autoconf, you need to write an Autoconf input file `configure.in' and run autoconf on it. If you write your own feature tests to supplement those that come with Autoconf, you might also write files called `aclocal.
autoreconf is a Autotool which is used to create automatically buildable source code for Unix-like systems. Autotool is a common name for autoconf, automake, etc. These all together are termed as Autotools.
PostgreSQL has a hacked version of AX_PTHREAD that addresses some problems: http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/config/acx_pthread.m4 . PostgreSQL builds on Mac OS X, so give it a try perhaps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With