autoconf with -pthread

别等时光非礼了梦想. 提交于 2019-12-23 07:22:59

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/1699113/autoconf-with-pthread

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!