WiP on stdatomic.h.
[platform/upstream/libatomic_ops.git] / configure.ac
1 # Process this file with autoconf to produce a configure script.
2 AC_INIT([libatomic_ops],[7.2alpha7])
3
4 AC_PREREQ(2.64)
5 AC_CANONICAL_TARGET([])
6 AC_CONFIG_SRCDIR(src/atomic_ops.c)
7 AC_CONFIG_MACRO_DIR([m4])
8 AM_INIT_AUTOMAKE([foreign dist-bzip2 nostdinc])
9 AM_MAINTAINER_MODE
10
11 AM_CONFIG_HEADER(src/config.h)
12
13 # Checks for programs.
14 AM_PROG_CC_C_O
15 AM_PROG_AS
16 LT_INIT([disable-shared])
17
18 # Checks for functions.
19 AC_FUNC_MMAP
20
21 # Determine PIC flag, adjust default CFLAGS
22 need_asm=false
23 PICFLAG=
24 AC_MSG_CHECKING(Determining PIC compiler flag)
25 if test "$GCC" = yes; then
26   AC_MSG_RESULT(-fPIC)
27   PICFLAG=-fPIC
28   case "$host" in
29     *-*-solaris*)
30       # Workaround: at least GCC 3.4.6 does not define this macro.
31       CFLAGS="$CFLAGS -D__PIC__=1"
32       ;;
33   esac
34   # Output all warnings.
35   CFLAGS="$CFLAGS -Wall -Wextra"
36 else
37   case "$host" in
38     *-*-hpux*)
39       AC_MSG_RESULT("+Z")
40       PICFLAG="+Z"
41       CFLAGS="$CFLAGS +O2 -mt"
42       ;;
43     *-*-solaris*)
44       AC_MSG_RESULT(-Kpic)
45       PICFLAG=-Kpic
46       CFLAGS="$CFLAGS -O"
47       need_asm=true
48       ;;
49     *-*-linux*)
50       AC_MSG_RESULT(-fPIC)
51       PICFLAG=-fPIC
52       # Any Linux compiler had better be gcc compatible.
53       ;;
54     *)
55       AC_MSG_RESULT("<none>")
56       ;;
57   esac
58 fi
59 CFLAGS="$CFLAGS -DNDEBUG"
60 AC_SUBST(PICFLAG)
61 AC_SUBST(DEFS)
62
63 AH_TEMPLATE([_PTHREADS], [Indicates the use of pthreads (NetBSD).])
64
65 THREADDLLIBS=
66 ## Libraries needed to support threads.
67 AC_CHECK_LIB(pthread, pthread_self, THREADDLLIBS="-lpthread",,)
68 AC_DEFINE(_REENTRANT, 1, [Required define if using POSIX threads.])
69 case "$host" in
70     *-*-netbsd*)
71       AC_DEFINE(_PTHREADS)
72       ;;
73     *-*-openbsd* | *-*-kfreebsd*-gnu | *-*-dgux*)
74       THREADDLLIBS=-pthread
75       ;;
76     *-*-cygwin* | *-*-darwin*)
77       THREADDLLIBS=
78       ;;
79 esac
80 AC_SUBST(THREADDLLIBS)
81
82 AM_CONDITIONAL(NEED_ASM, test x$need_asm = xtrue)
83
84 AC_CONFIG_FILES([
85         Makefile
86         doc/Makefile
87         src/Makefile
88         tests/Makefile
89         pkgconfig/atomic_ops.pc
90         pkgconfig/atomic_ops-uninstalled.pc
91         pkgconfig/atomic_ops_as_stdatomic.pc
92         pkgconfig/atomic_ops_as_stdatomic-uninstalled.pc ])
93
94 AC_CONFIG_COMMANDS([default],[[]],[[
95 PICFLAG="${PICFLAG}"
96 CC="${CC}"
97 DEFS="${DEFS}"
98 ]])
99 AC_OUTPUT