Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

autoconf with -pthread

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?

like image 256
vy32 Avatar asked Nov 09 '09 04:11

vy32


People also ask

What is autoconf used for?

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.

How do I set up autoconf?

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.

What is Autoreconf used for?

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.


1 Answers

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.

like image 187
Peter Eisentraut Avatar answered Sep 22 '22 09:09

Peter Eisentraut